Programmable LED How To

This is a tiny blinking device. The blinking sequence can be reprogrammed with the use of a flash light. It detects changes in lighting and records these changes and finally plays them back.
It is one of the simplest things you can do with a microcontroller. Slightly more complex than a blinking “Hello world”, but much more fun.

http://blip.tv/play/AYytV4OrfA

Here is a demo of programming it to play (morse) S.O.S.

How does it work

The LDR (Light Dependent Resistor) is used as input sensor to detect the light changes. It is attached to an ADC (Analog Digital Converter) port of the microcontroller. If the controller detects short light changes (dark, bright, dark or the other way round) it switches into recording mode. It records up to 10 seconds with 40 samples per second. Then it switches back to playback mode and plays the recorded sequence.

For more details and background on how to program the controller, please visit the instructable at Programmable LED Instructable.

Parts and Tools

First check if you have all needed parts.

  • ATtiny13v, microcontroller, 1024 bytes flash memory, 64 bytes RAM, preprogrammed
  • Resistor, 1k (brown, black, black, brown, brown)
  • Resistor, 10k (brown, black, black, red, brown)
  • Low power LED, 2mA, red or green
  • LDR, photocell
  • Coin cell, 3V, 220mAh, CR2032
  • Paperclip

To build it, you will need the following tools:

  • Soldering iron
  • Solder
  • Pliers
  • Third hand

Solder it

This circuit is build in, so called, free form. That means there is no PCB (Printed Circuit Board) involved. Components are soldered directly to each other. That can get a bit tricky but it will increase your patience. Also, note that you can not reprogram the controller, if you have soldered it as described below.

Bend the pins

First bend the legs of the microcontroller gently up.

ATtiny13 with bent legs

Bent them in a way, that the controller lays flat on the surface.

Then cut off unwanted pins. These are pin 1, 5 and 6. Or bend them a couple of times until they come off.

Next, bend the LDR.

And the resistors.

Cut the legs of the LDR to adjust the spacing between LDR and controller. Try to get the legs well aligned before you solder. Then solder the LDR to pin 2 and 3. The orientation of the LDR does not matter. Note that you should take care to not heat up the controller for too long as that will destroy it.

Solder the 10k resistor to pin 3 and 4. Cut to desired length.

Solder the 1k resistor to pin 7. Cut to length as well.

Bend the LED. As shown in the photo above, the upper leg is the kathode, the shorter leg.

Bend one leg of the resistor up.

Solder the longer leg of the LED to the resistor. Cut off the superfluous part of the leg.
Solder the shorter leg of the LED to pin 4 or the other resistor.

Bend up the inner part of the paperclip.

Next, after measuring with the coin cell, take the head of the paperclip and bend it up. The coin cell should fit tightly. You may have to bend it a while until it forms a good stand for the Programmable LED.

Now solder the paperclip to pin 8 of the controller. That is the pin for power supply.

We are almost done. Take a piece of wire or one of the cut off legs and solder it to pin 4 of the controller. That is the pin for ground. Adjust the length and form it to have a steady contact with the top of the coin cell.

Insert the coin cell with positive side on the bottom. And … that’s it. Now you are ready to program it.

Program it

When you insert the battery, the LED should flash 5 times. That’s a kind of hello. Next, it switches to programming mode, because it has no recorded sequence. Switching to programming mode is signalled with 5 fast flashes. Now you can record a 10 second sequence of light and dark before it switches to playback mode, signalled with 5 fast flashes as well.

You can re-enter the programming mode by giving it a short flash of half of a second. A flashlight works well or cover it with your hand to cast a shadow for half a second.

This is only one way to assemble the components. There are many others. Be sure to check out the gallery for more versions.

Links and Downloads