Programmable LED using Atmel ATtiny13v Microcontroller
Inspired by various LED Throwies, blinking LEDs and similar instructables I wanted to do my version of an LED controlled by a microcontroller.
The idea is to make the LED blinking sequence reprogrammable. This reprogramming can be done with light and shadow, e.g. you could use your flashlight.
This is my first instructable, any comments or corrections are welcome.
Update 12/08/2008: There is now a kit available at the Tinker Store.
Here is a video of reprogramming it. Sorry for the quality.
Step 1 How it works
The controller has two modes of operation, one for recording a sequence, the other for playing back the recorded sequence.
Once the controller notices two changes of brightness within half of a second, (dark, bright, dark or the other way round), it switches to recording mode. In recodring mode the input of the LDR is measured multiple times a second and stored on the chip. If the memory is exhausted, the controller switches back to playback mode and starts to play the recorded sequence.
As the memory of this tiny controller is very limited, 64 bytes (yes, bytes!), the controller is able to record 400 bits. That is space enough for 10 seconds with 40 samples per second.
Step 2 Materials and Tools
– 2 x 1K resistor
– 1 x LDR (Light Dependent Resistor), e.g. M9960
– 1 x Low-current LED, 1.7V, 2ma
– 1 x Atmel ATtiny13v, 1KB flash RAM, 64 Bytes RAM, 64 Bytes EEPROM, [email protected]
– 1 x CR2032, 3V, 220mAh
– soldering iron
– solder wire
– AVR programmer
– 5V power supply
– CDT plugin
Costs overall should be below 5$ without the tools.
I used the ATtiny13v because this version of this controller family is able to run at 1.8V. That makes it possible to run the circuit with a very small battery. To have it run for a very long time, I decided to use a low current LED which reaches full brightness already at 2ma.
Step 3 Schematics
Some comments on the schematic.
The reset input is not connected. This is not best practice. Better would be to use a 10K resistor as pull up. But it works fine for me without and it saves a resistor.
To keep the circuit as simple as possible, I used the internal oscillator. That means we save a crystal and two small capacitors. The internal oscillator lets the controller run at 1.2MHz which is more than enough speed for our purpose.
If you decide to use another power supply than 5V or to use another LEDs you have to calculate the resistor R1. The formula is: R = (Power supply V – LED V) / 0.002A = 1650 Ohm (Power supply = 5V, LED V = 1.7V). Using two low current LEDs instead of one, the formula looks like this: R = (Power supply V – 2 * LED V) / 0.002A = 800 Ohm. Please note, that you have to adjust the calculation if you choose another type of LED.
The value of the resistor R2 depends on the used LDR. 1KOhm works for me. You may want to use a potentiometer to find the best value. The cicuit should be able to detect light changes in normal daylight. To save power, PB3 is only set to high, if a measurement is done.
Update: the schematic was misleading. Below is a correct version. Thanks, dave_chatting.
For more Detail: Programmable LED using Atmel ATtiny13v Microcontroller
Leave a Comment
You must be logged in to post a comment.