#include uint8_t c = 0; /* Make sure the WDTON Fuse is unprogrammed */ int main() { DDRB = (1 << PB0) | (1 << PB2) | (1 << PB3); SPCR = (1 << SPE) | (1 << MSTR); WDTCR = (1 << WDP2) | (1 << WDP1); GIMSK = (1 << PCIE); PCMSK = (1 << PCINT4); sei(); while(1) { sleep_cpu(); } } uint8_t sent = 0; ISR(WDT_vect) { if(sent) { while(!(SPSR & (1 << SPIF))); } SPDR = c; c = 0; sent = 1; } ISR(PCINT0_vect) { if(c < -1 && (PORTB & (1 << PB4))) { c++; } }