↑ Return to Projects

Charlie and the Fire Fly

After working on the Matrix Medallion, I ran across a couple of articles on “Charlieplexing”, it looked interesting, so I wanted to give it a try.

One project in the back of my mind was trying to capture the essence of a jar of fire flies. I’d seen several projects around the internet that were built on LARGE jars, I wanted to represent it in miniature, almost like a ‘ship in a bottle’. The stumbling block had always been trying to fit the number of wires required to do traditional multiplexing into a small jar. I figured 3 or 4 wires was about all I could hope to reasonably work with in such a confined space. That’s when I stumbled across Charlieplexing.

I was wanting to drive 6 or 7 small 0603 size LED “fire flies”. Traditional multiplexing would require at least 5 wires, (2 rows & 3 columns) However, Charlieplexing uses tri-state logic so 3 wires can drive 6 LED’s. Note that this does not come for free. With Charlieplexing, you can only drive a single LED at a time and the control logic is a bit more complicated because you have to control 3 states of each output pin, hi, low, and High-Z.

There are serious limitations to what you can do with Charlieplexing. For example, you can only switch on 1 LED at a time (where as with traditional multiplexing a whole row is switched on at once), this means you need a higher refresh rate and the effective brightness may be reduced due to the reduced duty-cycle for each LED. In a normal 3×2 multiplex matrix, each LED is on 1/2 the display cycle time (50% each row). However with Charlieplexing, those same LED’s are only on for 1/6 the display cycle time.

You will also find that the wiring and software driver complexity increases greatly as each LED is added to the Charlieplexed matrix. In addition you’ll run into issues if all your LED’s do not have the same forward voltage as certain states may then turn on unwanted LED’s. However, I found Charlieplexing to be quite useful in this specific case. It’s definitely something useful to keep in your bag of tricks.

In order to control the LED’s you need to follow a state table similar to this:

A0 A1 A2 ‘On’ LED
L H Z #1
H L Z #2
Z L H #3
Z H L #4
H Z L #5
L Z H #6

This is what the total circuit looks like:

Charleplex firefly circuit

Charleplex firefly circuit

Assembly

There isn’t much assembly wise, just the ATTINY26L, 6 SMD LED’s, one capacitor, 3 wires and the CR2032 battery holder, that’s it! No circuit board, just solder everything together and mount it inside an appropriate container. Assembly is tight so I’ve got a few tricks to make things easier: Here’s the bottle I used for …

View page »

Circuit Diagram & Source

I use a USBTinyISP from LadyAda.net. It works just fine, however you need an adapter to program the SOIC ATTiny26L out of socket. All source code is written for WinAVR C compiler. It's a simple infinite loop that bit-bangs a PWM output to each of the 6 LED's. Cycle times are random. Each time you …

View page »