I have problem, microcontroller simply doesnt register when i press button. As it didnt happened. Here is my code.
#ifndef F_CPU
#define F_CPU 1000000UL
#endif
#define bit_is_clear(byte, bit) (!(byte & (1 << bit)))
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
typedef enum { false, true } boolean;
boolean clicked = false;
int sigurno_pritisnut = 0;
void pressed();
void unpressed();
int main(void)
{
//LED OUTPUT
DDRB |= (1 << PINB0) | (1 << PINB1) | (1 << PINB2);
//LED LOW
PORTB &= ~((1 << PINB0) | (1 << PINB1) | (1 << PINB2));
//BUTTON INPUT
DDRC &= ~(1 << PINC5);
//BUTTON HIGH
PORTC |= (1 << PINC5);
/* Replace with your application code */
while (1)
{
if(bit_is_clear(PINC, PINC5)){
sigurno_pritisnut++;
if(sigurno_pritisnut > 400){
clicked = !clicked;
sigurno_pritisnut = 0;
}
}
if(clicked){
pressed();
}else{
unpressed();
}
}
}
void pressed(){
PORTB ^= (1 << PINB0);
_delay_ms(500);
PORTB ^= (1 << PINB1);
_delay_ms(500);
PORTB ^= (1 << PINB2);
_delay_ms(500);
sigurno_pritisnut = 0;
}
void unpressed(){
PORTB ^= (1 << PINB0);
_delay_ms(500);
PORTB ^= (1 << PINB0);
PORTB ^= (1 << PINB1);
_delay_ms(500);
PORTB ^= (1 << PINB1);
PORTB ^= (1 << PINB2);
_delay_ms(500);
PORTB ^= (1 << PINB2);
}
................................................................... I have tried with other buttons, tried with other pins but nothing. ...................................................................