3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Synchronizing Fireflies

Synchronizing Fireflies
Have you ever asked yourself how do hundreds and thousands of fireflies are able to synchronize themselves? How does it work, that they are able to blink all together without having a kind of boss firefly?

This instructable gives a solution and shows how this synchronization can be achieved.

I have always been fascinated by self organization of insects. A couple of years ago I wrote a Java-Applet that simulates a square of thousands of fireflies. It worked well and was fun to watch. This time I have done it in hardware.

Credits for inspirations goes to Keso and his Jar of fireflies http://www.instructables.com/id/E7U5HYMSVIEWP86SAL/.

Any comments or corrections are welcome.

Update 2008-09-12: There is a new version of the fireflies online at Synchronizing Firefly Howto. It has a custom PCB for every firefly. And you can buy a kit at the Tinker Store.

Here is the video:


 
Remove these adsRemove these ads by Signing Up
 

Step 1How it works

How it works
The algorithm

What can be observed is that the fireflies start with random blinking. But as time goes by, they are able to slowly synchronize with their nearest neighbors. And these neighbors are synchronizing themselfes with their neighbors and so on an so on. Until the whole tree or the whole valley blinks in the same cycle.

And what is it good for? It is used to attract other specimen. With all the blinking in sync it is much easier to find a partner.

One of the easiest algorithm to explain this behaviour goes like this: You have a value that holds the power to flash. As time passes this power will slightly raise. If the power reaches a certain level, the firefly flashes and the power is consumed. The rate at which the power raises is nearly the same for all fireflies. So they have the same frequency but not the same point in time to flash.

While slowly charging with power the firefly is able to detect a flash of another firefly nearby. It adds then a higher value to its power value. Some kind of power boost, if you wish. That means the next flash will occur earlier than the one before. And next one even earlier, until these two are flashing exactly at the same point in time and with the same speed.

You can find more on this algorithm e.g. here:
Firefly Synchronization Ad Hoc Networks

The Hardware

I decided to use my previous instructable (Programmable LED) as starting point. It consists of a microcontroller, an LED and an Light Dependent Resistor (LDR). That should be enough to simulate a simple firefly. It is able to flash, to see and to count.

I just had to modify the program and the orientation of the LED and the LDR. LED and LDR must been placed in a way that one firefly circuit is able to interfere with another. So one LDR must be able to "see" the LED of another firefly. And it should not only see one neighbour but more. That can be done by letting the LED and the LDR pointing up from the ground and use some white paper to reflect the flashes.

« Previous StepDownload PDFView All StepsNext Step »
116 comments
1-40 of 116next »
Nov 30, 2011. 2:44 AMHamid_f says:
Hi Alex,
I remembered an old german tv documentary (maybe Spektrüm) about non-linear and chaotic systems, fractals and some structures called "cooperative aggregation" or "cooperative memory" (i don't know exact term), if you remove a little pixels of a picture after iterations lost information can be repaired (rebuilt). brightness of each pixel is sum of neighbors brightness with particular weight. a focused camera on a tv was setup of this idea. do you know about this?
May 17, 2012. 7:52 PMabend says:
That sounds a lot like Hopfield networks, which are a type of artificial neural network.
Sep 11, 2011. 6:01 PMknexsuperbuilderfreak says:
Why use a socket when you can soder the chip right to the board and you could bend the leds down maybe or they might just light a ton of them up.
Aug 5, 2010. 6:28 PMeulaliaaaa! says:
(Piano music) You would not believe your eyes, if ten million fireflies, Ate out your eyes and then farewell. They fill the open air, and scatter body parts everywhere, I don't mean to be rude but an arm is over there.
Aug 22, 2011. 12:19 PMtheawesomeninja says:
k I'd like to make myself go pee....But planet earth is gory. It's hard to stay coherent when I'm all but torn apart. And it appears my dog consumed my heart.....k
Aug 21, 2011. 6:52 PMtrailleadr says:
lmao, now that's funny!!
Sep 5, 2009. 7:50 PMGhost Wolf says:
Do you need to program every single ic?
Aug 22, 2011. 12:19 AMJD_Mortal says:
The "other way" would be to use an ATMEGA 328 P (Arduino Duemilanove) with a LED-ARRAY setup. This involves a slightly more complex program, but it saves you some soldering and hardware costs.

You use the 13 digital outputs to create a grid for the LEDs 6x7 = 42 max leds. You use the 6 analog inputs with 7 stacked resistors (making a grid array of inputs) with the light sensors. Or you can use less leds, and have the extra digital pins as part of the analog input array.

Since the LEDs don't need full power, or constant power to look ON... You turn on each led in the grid, of each row, while you cycle through the grid. (Look up the 3D LED array, and you will see what I am talking about.) Additionally, adding a capacitor to the LED will help it appear ON and brighter between grid cycles.

Plus you get the added bonus of being able to scroll letters and do a-life programs!

Love this setup BTW. Would be neat with them all freely inside a jar, frozen in epoxy or mounted on a screen in the jar.
Sep 6, 2009. 5:10 PMGhost Wolf says:
Once you turn it off (0Vs) will the ic lose it's memory?
Sep 7, 2009. 11:11 AMGhost Wolf says:
What is the main memory used for?
Sep 7, 2009. 6:44 PMGhost Wolf says:
Yes thank you very much
Sep 8, 2009. 7:30 PMGhost Wolf says:
Can you use different LEDs?
Sep 9, 2009. 9:17 PMGhost Wolf says:
Thanks i just wanted to know, a another question I have Is there any photos of the back side?
Sep 12, 2009. 11:33 AMGhost Wolf says:
I was just wondering because I want to how you supply power to the unit
Aug 21, 2011. 10:55 PMan1153 says:
LOL
Aug 21, 2011. 8:50 AMbroper says:
cool
Apr 10, 2011. 1:30 PMmkpeker says:
Thanks for your good project but unfortunately this circuit doesnt matches with the code on step7.

True circuit:

pin1: 10k to vcc
between pin2-3: LDR(best 10k LDR)
between 3-4: 1k resistor
pin4:GND
pin 5 and 6 not connected
pin7: green led by 220 ohm to GND
pin8:vcc

Thank you anyway
May 20, 2010. 2:03 AMelektroking says:
Hello
i have a tiny13 and want to put in te program of the fire flies but with mikroc PRO for AVR it doesn't work. Witch programmer have jou used for the program?

Kluzze 
May 3, 2010. 4:41 AMAndyGadget says:
Any chance of restoring the video?
I'd really like to see this.
Dec 27, 2009. 9:35 AMGOwin says:
 very nice!

Is there a way to "talk" to each firefly (ie ask one to turn itself on or off)?
Mar 7, 2009. 3:43 PMXenel says:
Synchronizing Christmas tree lights anyone?
Jul 18, 2009. 1:13 PMlasermaster3531 says:
cool!!
Jul 1, 2009. 7:30 AMtwist2b says:
What if I want to have a couple all over my room, they go off all day, but by night they can synchronize when there is no light. Here is the question though, how large of a distance can you get? And how can you make something like this to work with larger distances?
Jun 3, 2009. 1:26 PMo_k_boy says:
hi alex, great project - i'm a newcomer to avr programming and have been reading your blog and instructables carefully. they have been very useful, so thank you very much. i know this version of firefiles has been superseded now, but in the schematic you have the ldr positioned between pins 1 and 2 of the avr - is this correct or should it be between 2 and 3?
Jan 25, 2009. 12:29 PMuberdum05 says:
Could you do this with 1 arduino board and 5 photoresistor / led combinations??
Oct 30, 2008. 2:56 PMCarlos Marmo says:
Wonderful work! Much Style! Congratulations!
Sep 20, 2008. 4:55 PMGoodhart says:
Oh cool, a hardware version of Emergence theory......I will have to have a go at this in the future. :-)
Sep 15, 2008. 5:41 PMkiowamike says:
Great project! I am putting together the parts for this thing but, I am having trouble finding the LDR's. Since I don't speek Dutch or German, I was wondering if you have a Digikey.com part number. Thanks.
Sep 16, 2008. 9:17 PMkiowamike says:
Thanks a bunch. I'll give it a try and let you know how it works.
Aug 11, 2008. 5:10 AMazog says:
Great project, thinking about doing this. By the way, the link titled "Firefly Synchronization Ad Hoc Networks" (http://www.docomoeurolabs.de/pdf/publications/2006/2006_WSL_Firefly_Synchronization_Ad_Hoc_Networks.pdf) is dead.
1-40 of 116next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
45
Followers
4
Author:alex_weber