ATtiny13 – blinky with timer OVF (Overflow)

Yet another blinky project that is based on internal timer. In our circuit a LED is connected to PB0 and it is made to blink for roughly every second by using timer OVF (overflow). The code is on Github, click here.

Parts Required

Circuit Diagram



This code is written in C and can be compiled using the avr-gcc. More details on how compile this project is here.

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

#define LED_PIN PB0


        PORTB ^= _BV(LED_PIN); // toggle LED pin


        /* setup */
        DDRB = 0b00000001; // set LED pin as OUTPUT
        PORTB = 0b00000000; // set all pins to LOW
        TCCR0B |= _BV(CS02)|_BV(CS00); // set prescaler to 1024 (CLK=1200000Hz/1024/256=4Hz, 0.25s)
        TIMSK0 |= _BV(TOIE0); // enable Timer Overflow interrupt
        sei(); // enable global interrupts

        /* loop */
        while (1);

One thought on “ATtiny13 – blinky with timer OVF (Overflow)

  1. Hi,
    first of all thanks for above tutorials, i am currently working on toy based products, in which we are using IR based remote mechanism(NEC), we have used same controller at our side for remote design.but we are facing range problem; as we can talk to receiver module from 2-3 meters when we try to go above 3 meters receiver not responding.
    How to resolve this issue


Leave a Comment