#include #include #include #include int main(void) { uint8_t delay = 2; bool swSnel, swTraag, oldswSnel = false, oldswTraag = false; volatile uint16_t i; DDRB = 0xFF; PORTB = 0xFF; DDRA = 0x00; OCR0 = 36 * delay; TCCR0 = 0x0D; TIMSK |= 1< 1) OCR0 = --delay * 36; } for (i = 0; i < 3000; ++i); /* anti-dender vertraging */ } return 0; } ISR(TIMER0_COMP_vect) { static uint8_t patroon[] = { 0x00, 0x80, 0xC0, 0x40, 0x60, 0x20, 0x30, 0x10, 0x18, 0x08, 0x0C, 0x04, 0x06, 0x02, 0x03, 0x01, 0x00 }; static uint8_t j = 0; static bool heen = true; PORTB = ~patroon[j]; heen = heen ? ++j != sizeof patroon - 1 : --j == 0; }