LED Fireflies in a Jar
I’ve been trying to make electronic fireflies for ages now, and most of my previous attempts involved RGB LEDs, and one of them per ATtiny13 with code to flash a random colour now and again. This was always going to be a pretty expensive method, but after seeing http://www.instructables.com/id/Jar-of-Fireflies/ I realised it would be a much better idea to have one ATtiny13 control /many/ LEDs.
I wanted the first one to be in a jar, but in future I plan to have much longer wires so that I get one controller PCB and 12 fireflies extending off to cover a corner of a room, or part of a ceiling, etc. I could even add an LDR so it can detect dark, possibly by using pin 1 (so the chips couldn’t easily be reprogrammed).
The circuit schematic is kind of odd: I took a normal 2×3 matrix, where PB0 and PB1 control the two columns (as they can do PWM, so all LEDs can be PWM controlled), and added another LED for each position but in reverse. Since all the ouputs can tri-state (where effectively they act as though they were not connected), I can light up any LED I want individually.
While I could easily extend this to a full charlieplexing scheme, that would mean losing the hardware PWM for every LED. I could easily add another two LEDs between PB0 and PB1, but it’s really not worth the added complexity – 12 is plenty!
Each LED is an 0603 green LED soldered to two very thin wires, which run to a home made PCB at the top of the jar. The battery holder is a standard kind of cell holder from Rapid, and on the other side of the PCB is the ATtiny13 (soldered to the solder-side directly) and two 180 ohm resistors. The entire thing is through-the-hole because I don’t have any surface mounted ATtiny13s lying around and did have loads of 180 ohm through the hole resistors.
The code is fairly simple: in an infinite loop it chooses one LED at random, lights it up following a rough sine wave (actually modeled on a real firefly flash!) and then might repeat it once or twice, then waits a random amount of time before doing the whole thing again.
Each time the thing is turned on, a value is read from 0×00 in the internal EEPROM memory and used as the seed for the PRNG, then incremented and stored – giving 255 different patterns, more than enough that you can’t see any repetition!
By far the most difficult part of this was soldering all the tiny LEDs – if it wasn’t for that, this would be a particularly easy project to pull off. Using normal through-the-hole LEDs is an option, or even LED holders which would solder to the PCB and an LED just slots in. Surface mount ones are small enough to be less noticable and look better when lit up, though.
Eagle schematic and PCB file, C source code and compiled hex file available at: http://randomskk.net/projects/fireflies_in_jar all files are released under CC BY-SA-NC license



[...] to make electronic fireflies for quite some time and finally settled on a design he liked. His jar of fireflies uses an ATtiny13 to control a set of 12 matrixed LEDs. The green SMD LEDs are each soldered to a [...]
Jar of fireflies - Hack a Day said this on October 19th, 2008 at 1:01 am
looks cool dude ;o) for thinner wires you could use verowire from a wire wrap pen
Barry said this on October 19th, 2008 at 10:50 am
That’s a thought. I’m also considering 36SWG enamelled wire from Rapid but couldn’t order any in time for this project (it’s a birthday present). I may try again with some though, it would be an awful lot thinner.
I’d really like to do them without the jar, too – have them around the room or outside or something.
Random said this on October 19th, 2008 at 11:42 am
what about putting some plantlike things in there to make it more real. The wires could be the sticks.
o.t
nice idea.
flexy said this on October 19th, 2008 at 11:58 am
that’s a really really good idea! Wires could easily be hid running down sticks and the LEDs themselves could be placed on leaves etc. that would look way better than just the wires.
thanks for the suggestion!
Random said this on October 19th, 2008 at 12:00 pm
Looks cool, adam. I was also inspired by the same instructable as you were.
http://www.youtube.com/watch?v=-xdm_dVkR9s
-Matt
p.s. thanks for the tips on the light bar controller software, i used it in my RGB cubes project.
http://www.youtube.com/watch?v=9RriMdp90Mw
Matt said this on October 19th, 2008 at 8:09 pm
Those RGB cubes are really neat, great work! I really like your method for storing resistors as well, I may try something like that – a tiny tray for each one is way overkill, but putting them all together makes finding any one I want a complete pain.
Random said this on October 19th, 2008 at 8:18 pm
Hello, I’ve been looking for a site like yours since last Wednesday. The last place I searched (should be the first) was in Google, using the keywords “hid lighting”. Anyway, it was worth the search because I really like this website and your post regarding LED Fireflies in a Jar looks very interesting for me. Definitely Stumbled!
reece said this on October 29th, 2008 at 9:03 am
I am a little, well, very new to the idea of working with a programmable microcontroller such as the ATtiny13. I was searching for the device and I am unable to determine exactly which controller to purchase. I did help a friend work on a arduino for a underwater ROV, but my participation was limited. Any help you can provide would be greatly appreciated.
Jacob said this on December 3rd, 2008 at 8:44 pm
I would advise getting an Arduino to start with – they are very easy to program over USB with no need for an external programmer, and their software has everything already working, so you don’t have to fuss about with compilers and such.
Random said this on December 3rd, 2008 at 9:23 pm