About a year ago I started on a project to make a temperature controlled nightlight. I was inspired by seeing these lovely LED lamps styled as mushrooms growing out of pieces of wood. Those mushrooms were made out of glass, which was somewhat beyond my skills. However I then saw some had used translucent sculpey to make mushroom nightlights on instructables. So with that discovery it seemed like it would be rather simple to do…
For some reason I got seized by the idea of creating some electronics for our Halloween costumes this year. In previous years I have gone as far as dying my hair green for Halloween, but that is just an evening’s work. This year we were having a more sedate affair – it being our first Halloween as parents.
We settled on making spider costumes. Basically black clothing, with extra arms made out of tights. I then decided that as spiders have eight eyes that making some hats with six extra eyes would make sense. After initially thinking I would just hook up some LEDs straight to a battery I decided to massively complicate matters by and try to make them blink periodically (at random).
So for this act of over-complication I chose to use the PICAXE 08m microprocessor. The core circuit (minus ability to program) is essentially just 3AA batteries, the chip itself and two resistors – so at least for a circuit involving a microprocessor wasn’t that byzantine. That is kind of the point of a microprocessor though. To the end-user it hides it’s internal complexity away. I don’t really need to know how many hundreds or thousands of transistors it contains internally. I only need to think about how it fits into my circuit.
I chose to have six LEDs to create pairs of “eyes” that would blink in tandem. This meant the PICAXE chip would turn three output pins on and off at random intervals. With a 4.5V power supply two LEDs wouldn’t need a massive current limiting resistor – 100Ohm would be sufficient. So the circuit consists of the 08m chip, two resistors (10KOhm and 22KOhm) to pull-down the serial-in pin, a 100nF capacitor to even the power supply, six LEDs and three 100Ohm current limiting resistors:
It’s not actually that complex a circuit, but spending several hours soldering it up (twice) for a couple of hours at a party might have been overkill. Still it was good practice. I also got to try out fitting everything into some project boxes and generally making things look “proper”.
I used perfboard for the finished circuit, with some holes enlarged to accept screws for the project box. I also added some extra holes so I could loop the power and LED wires through. This helped to make the connections nice and sturdy.
The chips were programmed using a different circuit, with the serial adapter attached and were then removed from their sockets and inserted into the soldered circuits. The two hats had slightly different programs uploaded to tweak the speed and random nature of the blinking (so they wouldn’t be too similar). The code is viewable at my picaxe08m repository on github (as well as a Fritzing file for the circuit). I did encounter a bug in the PICAXE compiler whilst writing this code. When I started using subroutines (and the gosub call) MacAXEPad would suddenly say “Hardware not found” when attempting to upload. Apparently this problem only affects the Mac version of AXEPad. Luckily there was an easy fix – simply adding a dummy sub-routine at the end of the file:
The finished result looked a bit goofy, but it did work. The main problem though was that it only really worked when the light was low. Not a bad problem for halloween I guess:
After I got my Arduino I felt the urge to brush up on my general electronics knowledge. The last time I’d really played with any circuits was back in about 1994 when I was studying my Technology GCSE – which now is quite a long time ago. So I picked up a copy of Make: Electronics and started reading through it. Sadly I was a bit lazy and just read through the book, rather than actually building many of the circuits suggested. It did come in handy for tips on soldering and I do intend to go back and make some of the circuits – I just got a bit distracted by a new arrival. However the last chapter covered microcontrollers and in particular the Picaxe 08m chip. This really piqued my interest!
The Picaxe 08m is a PIC chip with a pre-installed boot-loader that allows programming the chip via a serial port. This is similar to the way that the Arduino has an AVR chip with a pre-installed boot-loader. There’s also some software for the Picaxe for handling the programming, a bit like the Arduino IDE.
The 08m is massively less powerful than an Arduino. It has 512 *bytes* of program storage and only 14 *bytes* of variable RAM. However it has 5 outputs/4 inputs and can run a single servo. In fact I could have used it for the logic part of my Arduino doorbell. It’s not quite as friendly to get started with as an Arduino though. You need to wire up a simple circuit before you can get going. In fact I actually had to solder together a prototyping board, as I didn’t have much luck trying to used a breadboard. The circuit needed isn’t that complex (assuming you use 3AA batteries for power). The cost of the 08m chip is less that £2. The proto-board is £2, so altogether you can have a simple usable microprocessor for less than £4. It’s also small and doesn’t use much power. So for projects where an Arduino is overkill it’s perfect.
To make testing out circuits easier I also added a female header to the board, so I could plug in breadboard jumper cables (in the same way as one does with an Arduino Duemilanove):
To verify everything worked I wrote the “hello world” program of microcontroller world, a program that simply blinks an LED (by turning pin 1 on and off):
That’s Picaxe BASIC by the way. Maybe not as pretty as C, but for a processor with only 14 byte sized variables it’s more than enough.
Then I wired up an LED into the prototype board, along with a small current limiting resistor:
Using the Mac version of AXEPad and the Picaxe USB serial cable (which has a stereo socket at one end) I uploaded the program to the 08m chip and saw the LED blinking once every second. I’ve recorded a video of the programming, which should show how straightforward it is:
I’ve got a few projects in mind that are actually space/weight constrained and one in particular that might put the parts involved into extreme peril, so having the option of using a very small and cheap microcontroller is very appealing. I’ll reserve the Arduino now for projects that need it’s extra power and amazing flexibility.