Pfad: Home => AVR overview => Applications => Led light
LED light

Led light with an ATtiny13

All started in the parking lot of my supermarket: while deboarding my car I saw her. A short chain of LEDs tied to a plastic case for two AAA size batteries and a small switch. Of course, the plastic case was damaged, and there were no batteries there any more. Would those light idiots still do what they were supposed to: to produce light when current runs throught them?

Now, they all did it, even though in a parking lot many cars must have been ran over them. So I decided to recycle this small piece of chinese soldering art physically. From waste to something different. With three wonderful Volts the full yellow, red, green and blue light hammer. But the chain is somewhat boring, when there is no blinking, no soft on and off intensity changes, just on or off, and nothing else.

For a microprofessor junkie, that's not a big thing: put some action to the chain. And: depending from my mood, slow or fast. And: depending from the daytime, so light or dark. And: depending from the time of the year, four different sequences. Not only boring blinking, but a large number of different flows in between.

What the device does

It can

The scheme

And here that is all to bring some life to the LED chain.


In the center, there is a mikroprofessor, Mr. ATtiny13, because I always have it on stock in my electronic boxes. Of course one of the smallest available, because we don't need more and because assembler produces so small hex code (C programmers, that aren't able for something else now can change to other webpages and can program a 96-pole ATxmega elefant to get their LED light dimmed).

The four-pole mini switch for mood- and sequence-selection is connected to the portpins PB0, PB2, PB3 and PB4. To get clear signals when the switches are open the internal pull-ups tie these input pins to the operating voltage. The switches S1 and S2 arfe decoupled by 1k resistors from the portpins to allow for In-System-Programming (ISP) to not interfere with MOSI and SCK during ISP.

The portpin PB1 (OC0B) is switched as output and drives, via a 1k resistor, the transistor BD137. Here, the PWM modulated output signal switches the LEDs on and off. In the collector a resistor of 39 Ohms reduces the LED current, because the chain was designed for 3V operating voltage.

For those that don't find LED chains in parking lots can build their own. If you like it green you can use low-current-LEDs for that purpose. Those who like to bring more light to the street can use extra high-current-LEDs. The BD137 can switch up to 1.5 A. But the resistors must have other values then.

The ISP interface can be used to change the stored sequences if you get bored by the four different ones once programmed.

For the supply I had a 5V supply for an old Palm PDA and recycled this, too. To filter the DC current, the 220µF electrolytic condensator brings some storage space.


I started mounting the device on a breadboard.


After anything went fine and the program was debugged, anything was soldered on a small breadboard and build into a small plastic box.



The commented software is, of course, written in assembler. The source code in Assembler-/Text-Format can be found here, in HTML-Format here.

To the top of page

©2012 by