#include <avr/io.h>
#include <stdint.h>

void wacht1sec() {
    uint8_t count30 = 30, mark80 = 80;
    
    TCNT0 = 0;
    TCCR0 &= ~(1<<WGM01 | 1<<WGM00 | 1<<CS01);
    TCCR0 |= 1<<CS02 | 1<<CS00;

    do {
        while (TCNT0 != mark80);
        mark80 += 80;
        --count30;
    }
    while (count30 != 0);

    TCCR0 &= ~(1<<CS02 | 1<<CS01 | 1<<CS00);
}

int main(void) {
    void wacht1sec();

    DDRB = 0xFF;
    PORTB = 0xFF; /* alle LEDs uit */
    while (1) {
        wacht1sec();
        PORTB ^= 1<<7; /* flip LED 7 */
    }
    return 0;
}
