#include <avr/io.h> #include "avr/interrupt.h" uint8_t count; /* Timer 0 Interrupt */ ISR(TIMER0_OVF_vect){ count++; if(count==20){ count=0; // Toogle LED PORTB=PORTB ^ 0x20; } } int main(void) { TMR0_init(); DDRB |= 1<<DDRB5; // Direction of pin PB5 set as Output /* Replace with your application code */ while (1) { } } /******************************************************************************** TMR 0 Initialization ********************************************************************************/ void TMR0_init( void ){ // enable timer overflow interrupt for both Timer0 and Timer1 TIMSK0=(1 <<TOIE0) ; // set timer0 counter initial value to 0 TCNT0=0x00; // start timer0 with /1024 prescaler TCCR0B = (1 <<CS02) | (1<<CS00); // enable interrupts sei(); }