Mother's Day was approaching, and I am getting my 8 year old son started with electronics. So why not combine the two? In the next few pages we'll show you the project we did - a blinking heart with several effects, all driven by a microcontroller. Taught my son not only about how to make mommy happy (she LOVED the present), but also about project planning, prototyping, soldering, programming, and testing. Everything a budding little engineer needs!
By the way, if you like this project you may want to check out some other electronics design instructables I did:
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Circuit Design and Assembly
As this was a learning project for my son, I wanted to keep everything as simple as possible. We started out breadboarding some fundamental circuits - hooking up the microcontroller, blinking a single LED, and so on. Then we decided about the layout of the LEDs and went scavenging for the necessary components in my lab in our basement.
As for the microcontroller, we used a Picaxe 18A (see http://www.picaxe.com for more info). Picaxes are a line of very simple-to-use microcontrollers, perfect for our task. The 18A is actually a pretty old model, but was sufficient for the task. Apart from programming them in a simple version of Basic it also offers flowchart programming - this is what we ended up using since for an 8-year old I think it is way more intuitive. Nothing better than having a visual representation of the program flow.
The circuit schematic is shown above; nothing out of the ordinary. The circuit runs off two rechargeable batteries. The currents into the LEDs are low enough that the microcontroller can drive them directly. The pushbutton shown in the actual circuit ended up not getting used so I omitted it from the schematic. The Picaxe has a bootloader installed and is programmed through a simple serial interface - two resistors and a 3.5mm stereo jack is all it needs for that.
You may notice that there are always two LEDs hooked up to each output of the microcontroller, which means they aren't independent. This was again to limit complexity - that way all LEDs can be driven from a single port. Using a larger microcontroller with more outputs would have been possible but I wanted to avoid the code bloat that would result - I rather have a smaller program that my son can actually understand and handle. The way that the LEDs are hooked up - the LEDs of each pair are sitting at opposite ends of the heart - still allows for lots of interesting patterns.
We built up the circuit on a standard prototype board. It was the first time my son did some soldering (under very close supervision by myself to be sure), he was very excited. Above you can see the final result.
Step 2: Enclosure
Next thing was the enclosure (box). I had found a suitable one in my drawer which even had a battery compartment. The board fit pretty tightly.
In order do drill the holes accurately we got another protoboard where we marked the location of the LEDs on the "real" board. With a needle we could punch through the two mounting holes for each position and then drill the box right between each of these two marks. This worked pretty well and we were able to fit all the LEDs through the holes.
The batteries are standard rechargeable NiMH type AA cells, held in place with a battery holder.
Step 3: Programming
As mentioned before, the Picaxe can be programmed by drawing simple flow diagrams, using a program called "Logicator". This software is available for free from http://www.picaxe.com as well. You drag and drop the appropriate elements from a toolbar into the drawing area, and then connect them with arrows to indicate the flow of actions. Double-clicking on an element brings up a window where you can change its parameters (e.g. which pin you want to turn on or off). One nice feature is that you can simulate the program on the computer, so you can observe what each command does.
Again we started with simple experiments, e.g. toggling one LED on or off. Then we went to designing the different optical effects, one at the time, e.g. blink all LEDs together, or turn on successively more LEDs and then turn them off again one by one. In the end we joined all the separate effects together. Overall this taught my son a lot about programming, including debugging ("Why doesn't it work?" - "Well, lets go through step by step"). You find a screenshot of the complete program above, and below I attached the complete source code which you can download to us as a starting point for your own version.
Step 4: Finished Project
Below I have added some pictures and a video of the final version in action. Of course anybody can get creative and come up with his or her own special effects - the ones we did are by no means all that are possible!
I was expecting maybe a day or two of battery life; after all, LEDs are relatively power-hungry beasts. But it turns out that it lasts well over a week on a set of 1800 mAh rechargable batteries - not bad!