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
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 .