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

uint8_t i = 0;

ISR(TIMER0_OVF_vect) {
    ++i;
    if (i == 10) {
        i = 0;
        TCNT0 = 160;
        PORTB ^= 1<<7; /* flip LED7 */
    }
}

int main(void) {
    DDRB = 0xFF;
    PORTB = 0xFF; /* alle LEDs uit */
    DDRA = 0x00;

    TCNT0 = 160;
    TCCR0 &= ~(1<<WGM01 | 1<<WGM00 | 1<<CS01);
    TCCR0 |= 1<<CS02 | 1<<CS00;
    TIMSK |= 1<<TOIE0;

    sei();

    while (1) {
        if (PINA & 1<<6) 
            PORTB |= 1<<6;
        else
            PORTB &= ~(1<<6);
    }

    return 0;
}
