ATTINY85 – flash multiple LEDs

Similar to our previous example, in this case we connect 3 LEDs up to Pin 5, 6 and 7 which are PB0,1 and 2

Here is the schematic for this example

Schematic

attiny85 three LEDs

Source

[cpp]

#include <avr/io.h>
#define F_CPU 1000000UL
#include <util/delay.h>
int main (void)
{
// port B pins 0, 1, 2 as output
DDRB = (1 << PB2) | (1 << PB1) | (1 << PB0);

unsigned int i = 0;
while(1)
{
PORTB = i & ( (1 << PB2) | (1 << PB1) | (1 << PB0) );

i = (i+1) % 8;

_delay_ms( 500 );
}
}

[/cpp]

Related posts

ATmega128 and MAX7219 8 x 8 matrix

Atmega128 and a 7 segment display

Atmega16 and MAX7219 seven segment display