Introduction: New Jar of Fireflies
I wanted to go a step farther when I built the firefly jar as a Christmas present. My goal was to have multiple fireflies interacting, including males that sometimes synchronize with each other, and females that respond to the flashes of males. I also wanted to base it on the behavior of our backyard firefly, Photinus pyralis , the common Eastern firefly, which is also one of the best studied. I wrote my own software for the microcontroller to simulate this behavior. The full project is documented here , but this Instructable should be enough to follow.
The latest version of the firmware is available on GitHub .
You will need two things to use this software:
- An AVR-based LED array that follows the schematic in the original Jar of Fireflies Instructable with an ATtiny45 or ATtiny85 microcontroller.
- A means to program it. I use a 6-pin header connected to a USBtinyISP.
I tried making a video to demonstrate the flashing behavior. The quality isn't great (it's from an iPhone, and I reduced the quality to upload it):
Step 1: Hardware
The only changes I made to the original hardware were the addition of a push on/push off switch (scavenged from a stick-on LED light) and a 6-pin programming header to allow reprogramming of the jar after it had been built. To make testing and debugging easier, I also built a prototype board on a 2"x2" perfboard with the same schematic, so it is electrically identical but easier to see what it's doing, and less fragile. I've added a view of the point-to-point soldering on the back of the prototype board in case that is helpful to anyone. The prototype board can also be used as a target board for programming ATtiny85 (and -45) chips for other purposes. In the real jar, the switch and header are fixed to the underside of the lid with J-B Qwik to keep them well attached.
Step 2: Software
The simulated fireflies exhibit the following behavior, based on observations of the species Photinus pyralis , the common Eastern firefly (more details and references ):
- Male fireflies will appear one at a time, flashing at a regular interval, 5.9 ± 0.6 seconds, and gradually synchronize with each other.
- If all males are in sync, a female may respond to a male's flash after a delay of 2.1 ± 0.2 seconds. The appearance of another male out of sync will cause the female to stop responding to the first one. The female's flash is 1/10 the intensity of the males'.
- Each pulse is 0.5 second in duration with a steep increase and slower falloff, which I modeled as y=x*e-x2
- Females are stationary, they will flash at the same LED each time, while males can "move" around, flashing at randomly selected LEDs.
- One reaching the end state of 6 males flashing and one female responding, it will continue that pattern until it is reset at a random interval, about 5-20 minutes.
Download the source code and compiled .hex files here .