December 7th, 2006

I love das blinken LEDs!

J's LED driver

I wrote about the blinken LEDs for J earlier.

My approach was simple: use an 8-pin 12F675 PIC, and charlieplex four pins into 12 blinking LEDs. I built a small testing board and wrote the program to test the concept and schematic. It turns out that the pull-ups of the 12F675 are too weak to withstand the LED current -- which results in all LEDs glowing softly while one (the one that is supposed to be on) burns brightly. This renders the 12F675 useless for charlieplexing -- which is a real pity because the small footprint makes it very attractive to use that technique to maximise the number of LEDs that can be driven.
I should have realised this -- back in April I had some problems with the 12F675 precisely because the pull-ups are weaker than those in the 16F628A.

The same code worked pretty well in the 12F628A, though. I had almost reworked the board to accept my 18-pin workhorse of choice, when I realised that there was absolutely no need to charlieplex!
Sure, I could drive 12 LEDs with only 4 pins -- but why bother if I have fourteen pins at my disposal!? I had been so set on charlieplexing that I completely failed to re-adjust the schematic to the new parts I used.

So in the end, we built a schematic with fourteen direct-drive LEDs, with each LED connected to a pair of wires roughly the length of an A4 paper. I also added battery holders for three AA batteries and a switch (ghetto-style glued to the board with hot glue), and that was that.

As for the software, I used a linear feedback shift register as source for the pseudo-random patterns. For the timing, I used the one-second timer routine (based on the internal 4MHz oscillator -- not as precise as using a crystal, but this application is not time-critical), but I halved the number of clock cycles.
This results in a system that drives fourteen LEDs, blinking in another pseudo-random pattern every half second.

Tomorrow, J's work is being graded. I'm curious as to what she made of it, and her grade!