LED Fireflies in a Jar

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.

LED Fireflies in a Jar

LED Fireflies in a Jar

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

PCBs from Golden Phoenix arrive

I guess my new project has officially started! The PCBs I ordered from Golden Phoenix arrived today, a day short of two weeks from when I placed the order.
They’ve turned out really nicely, and I especially like the black soldermask. I plan to reflow solder the components on these using the grill in the oven [...]

Nixie Tubes: Lit up at last!

I know I got them months and months ago, but I’ve only just had time to actually do anything besides work. While I do have a big project coming up (but not really at the point where I can write about it), I did finally make the PCB for the nixie power supply I designed [...]

Nixie Tubes Arrived!

The twelve nixie tubes (and corresponding driver ICs) I ordered two weeks ago arrived today from http://tubes-store.com in Russia. They were beautifully packaged in two layers of foam and a cardboard box from some kind of kid’s milk in Russia. All the tubes are intact and in great condition considering they were made in mid [...]

Night Nerf

I’m off to Mongolia for a month in only five days, and one of the toys I’ll be bringing is a Nerf Vertex, basically you throw it and it whistles as it moves and you can catch it and all that fun stuff.
It does have one problem out of the box, though - you can’t [...]

Robot 1 Prototype

This is my first prototype robot. A friend and I got together and he taped stuff to cardboard while I connected wires up and then we wrote a basic program and the prototype drove!
This version literally just drives forward until the ultrasonic sensor detects an obstacle, then it turns and drives forwards again. We can [...]

Final Lightbar Controller

I’ve finished the lightbar controller!

This device analyses the music it picks up via the electret microphone, then flashes the LEDs in time to the music. It’s encased in the box SparkFun sent me the microphones in, since the box was just begging to be used as a case for something! I’m sure that was intentionally [...]

Modifying an HS-311 Servo for Continuous Rotation

I’m having a play with robotics stuff now, and one of the first steps was to get something moving.

I ordered some cheapo servos from ServoShop UK and had a play, they work fine.
However, to use them as easy-to-drive motors for wheels and stuff, you need to modify them to have unlimited rotation (they normally only [...]

Dual LED Matrix Message Board

Well, the second matrix for my LED message board arrived today!

It took a little change in the code to get it working with two matrices, but now it rocks!
Check out the video of it in action:

New Parts Bins!

At the same time I got my new brush/scourer, I also got four 16-tray storage containers which were some £2/ea and looked ideal for holding all my parts, which had grown out of hand in the previous containers.
I quickly loaded them up and just got around to printing out some labels on cardstock and sorting [...]