/*I`m connecting a Tacticle switch to the T0 pin on PORTB and enabling the pin as input , pullup resistor*/
DDRB =0x00; //PB0 Direction is Input
PORTB|=(1<<0); //Enabling internal pullup resistor
DDRC =0xff; //PORTC Direction is output
TCCR0 |=(1<<CS01)|(1<<CS02)|(1<<FOC0); //External Clock Source , Falling Edge
PORTC^=0xff; //Toggle PORTC whenever TCNT0 = 5
I`m Using timer0 to count how many times the switch has been pushed , the switch is connected to pin T0 on portB , .......... whenever the TCNT0 reaches 5 that means i pushed the switch 5 times the LED on PortC should be toggled ,
The problem is the LED is toggling whenever i push the switch 4 times and sometimes 2 times , can anyone explain to me why does this behviour occur?