/*
* ATtiny85 Blink w/Timer Overflow
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#define ledPin PB0
ISR(TIMER0_OVF_vect)
{
static byte cnt=0;
if (++cnt > 10){
PORTB ^= _BV(ledPin); // toggle led pin
cnt = 0;
}
}
int main(void)
{
// setup
DDRB |= (1<<ledPin);
PORTB &= ~(1<<ledPin);
TCCR0B |= _BV(CS02) | _BV(CS00); // set prescale to 1024
TIMSK |= _BV(TOIE0); // enable timer overflow interrupt
sei(); // enable global interrupt
// loop
while (1);
}