- Low cost and low part count
- Four different flashing patterns, easily modifyable
- Speed control and pattern switching via pot
This is nothing special, really. "Knight Rider lights" or "Larson Scanners" seem to be very popular microcontroller projects. I guess they are the next step right after the blinking LED (a.k.a. the "Hello World" program for microcontrollers).
I was recently asked if I could draw a schematic for such a device and in the end I decided to actually build the circuit. That way I could turn it into a blog post and make it available to a wider audience. The other point was that I could get my kids involved in building this.
This version is not exactly a beginner's project, because the charlieplexing is quite complex and turning the schematic into wiring can be a little confusing. So perhaps it is a good project to improve your soldering skills.
In this project 4 IO pins of an ATtiny13V are used. By employing charlieplexing, 12 LEDs can be controlled. The remaining available pin on the controller is configured as an input. Via ADC, the voltage output from a pot is read and used to control the speed of the pattern sequence. The "full speed" setting also serves as the pattern switching position. Four patterns are available. Changing them in the source code is simple, since they are coded as simple sequences of LED switch-on commands.
Basically there are the LEDs. I am using 12 red ultrabright LEDs, left-overs from another project.
Then there is the controller, an Atmel ATtiny13V. "V" stands for low voltage and means that the controller is happy to run from two alkaline cells (down to 1.8 Volts). A socket might be a good idea, especially if you want to reprogram it.
Finally there is the pot (missing in the photo above). Mine is of the 10k linear variety, but anything between 1k and 1M will be fine.
Perhaps I should mention the perf board as well, it is 50 x 100 mm. This is just wide enough to fit the 12 LEDs on.
In principle, it is very simple. Only the charlieplexing can be confusing. Just keep in mind that with charlieplexing the point is to have one LED between any two IO pins in either direction.
The pot just outputs a voltage between 0 Volts and the battery "+" voltage.
Since the controller pins limit LED current, no series resistors are needed. I measured an LED current of about 10 mA with my set-up and with batteries at 2.6 Volts (about 50% discharged). LEDs are usually rated at 20 mA, so we are on the safe side of things.
Start by inserting the LEDs in the board.
Take care to insert them so that the longer wire shows towards the edge of the PCB.
To avoid the LEDs falling out, bend the wires slightly outward.
Solder the LEDs to the perfboard and clip the wires. Mine isn't soldered perfectly, I know. It, wasn't me, honest. :-)
Next, add the IC socket. Somewhere in the middle is a good idea...
These groups are then connected to their respective controller port pins. The wires don't have to be green. :-)
Perhaps it would have been a better idea to put those wires on the bottom of the board. By putting them on top I created a kind of wire weave...
Now all cathodes are going to be connected. I started with the second port pin (PB1) - just to confuse you even more.
Next, I soldered the third port pin connections (PB2).
Keep going with the 4th port pin (PB3).
Finally, the first port pin is connected (PB0). Also, I added the power lines on the IC. Almost done!
There is one component left to connect: The pot. And voilà, the hardware is finished.
And if you want to see the thing in action, look here: