Prototype PCBs and firmware for “Jar of Fireflies” kit

Added on April 1, 2013

Over a year ago, I created a small batch of mason jars outfitted with LEDs that blink to mimic the behavior of fireflies. Since then, I’ve gained a bit more experience with CAD and PCB production so I thought it would be a great project to turn into a kit.

In addition to transferring the original schematic into a PCB, I added a few cool new features to make it even better. Right now, the kit includes the following:

  • ATTiny85 running code using HLT’s Arduino bootloader.
  • Six charlieplexed LEDs, instead of the original four.
  • A piezo sensor so you can tap on the jar to interact with it.
  • Circular PCB so it can be directly installed in mason jars.
  • A variety of power options via external breakout boards, including DC barrel jack, USB port and batteries.

All of the source files, including firmware, Eagle files and BOMs, can be downloaded for free at the project’s Github repo:

Get the source files on Github

Schematic and PCB design

I started by creating a basic schematic in Eagle, then designing a PCB from the schematic. I made a circle on the Dimension layer that is 3.2″ in diameter, so that the PCB would be cut in that shape and fit my mason jars in place of the lid. Since the number of parts was really low, it wasn’t too difficult to place the parts on the PCB and get all the routing done. You can download the Eagle files at the Github link above.

I used Seeed Studio’s Fusion PCB Service to manufacture the PCBs, which turned out much better than I was expecting. Components were ordered from Digikey, and after a couple weeks I was ready to start testing the prototypes.

Prototype assembly and firmware testing

After messing up the first PCB and turning it into a fashionable coaster, I assembled one PCB without much difficulty. I wrote some basic firmware to cycle through each LED and uploaded it to an ATTiny85, but it wouldn’t work. The code was so simple that I just couldn’t see anything wrong with it. I posed the question to the Arduino forums and got a pretty funny answer. Apparently, you can’t use variable names like PORTA/PORTB/PORTC because the AVR chips already reserve those names for internal use. You also can’t use the names PINA/PINB/PINC for the exact same reason! However, names like pinA/pinB/pinC work just fine – gotta love microcontroller programming.

Currently, the firmware will randomly fade in, blink and fade out individual LEDs. The time it takes to do all of these actions is slightly randomized so that when you watch it, you can’t really predict when something will happen.

Next steps

When I find some time, I plan on adding a piezo sensor to allow users to tap on the jar and interact with the LEDs. My early tests so far have stymied my original idea, which was to have all the LEDs flash in unison when you tap on the jar enough. Using the charlieplexing scheme you actually can’t physically do that with the LEDs. Right now my plate is a little full with other projects, but in mid-May I should be able to return to this project and finish up the firmware!