#include #include void setup() { TCCR0A = 0; TCCR0B = 5; TIMSK0 = 1; sei(); DDRB |= 0x20; } volatile unsigned long count = 0; // bad executable if initialized to 0!!! void loop() { ATOMIC_BLOCK(ATOMIC_FORCEON) { if (count > 50) { PORTB ^= 0x20; count = 0; } } } ISR(TIMER0_OVF_vect) { ++count; } int main() { setup(); while (1) { loop(); } }