Synchronizing Fireflies NG

s-dsc_0080.JPG

Update 04. Dec. 2008: This article is replaced by the new howto.

This is a remake of the fireflies which I did a year ago. I was always fascinated by the emergence of patterns. One I like most is the synchronization of hundreds or thousands of fireflies. First they flash randomly but after some time and influencing each other, they flash in sync.

This circuit simulates fireflies with small microcontrollers. Note that every firefly acts completely autonomously, it is not a preprogrammed pattern. It is a self organizing system.

The NG version uses a small PCB (Printed Circuit Board) and a RGB-LED.

Software

Each firefly has a value that stands for the power to flash. This value rises over time. If the power reaches a certain limit, the firefly flashes and the power is reset to zero. If the firefly detects another flash nearby, it increases the power by a small boost value. That way it will flash slightly earlier than last time. Doing so over and over again may lead to all fireflies flashing in sync.

The RGB-firefly uses color to express its mood. If all is in sync, it will flash in relaxed and cool blue. If it detects flashes that are not in sync, it will get a bit uncomfortable and the color will slightly change to green, yellow and red.

The circuit

Firefly schematic

The circuit is rather simple. Main parts are the microcontroller, the light sensor and the RGB-LED. The sensor and R4 are forming a voltage divider. An ADC (Analog Digital Conversion) channel at pin 3 is used to read the values of the sensor. The circuit is designed for 5V power supply. It has no integrated power regulator.

Parts

dsc_0008-s.JPG

Here are the parts, that are needed for a single firefly.

  • Firefly PCB
  • ATtiny13v, digi-key
  • RGB-LED, 4000 mcd, generic
  • 8-pin socket, generic
  • 3 * 100R resistor, R1, R2, R3, generic
  • 1 * 4.7kR resistor, R4, generic
  • Photoresistor (LDR), 4k to 11kR
  • pin header and socket (used for power supply)
  • ping pong ball

Various types of photoresistors exist. I tried two different versions and both work well. Only resistor R4 has to be adjusted, as R4 and the photoresistor are building a voltage divider. Choose R4 in a way, that gives you a good range of voltage and still limits the current through the photoresistor.

My latest experiments showed that a phototransistor seems even better suited. Compared to the LDR, it does not have a memory effect and reacts faster (~5ms compared to ~50ms). I chose the SFH 3310 and 100k for R4.

One thing to remember while choosing a light sensor, is that the spectral sensitivity of the sensor has to match the humans eye sensitivity (~400 nm – ~700 nm).

Solder it

s-dsc_0011.JPG

First solder the power connectors. Having a female and male connectors on the boards makes it easy to power a couple in a row.

s-dsc_0012.JPG

s-dsc_0013.JPG

Next insert the resistors. R1-3 are 100R, R4 is 4.7kR (depends on the sensor).

s-dsc_0015.JPG

Solder them.

s-dsc_0016.JPG

Cut off the legs.

s-dsc_0018.JPG

Next insert the 8-pin header for the controller. Note that the notch of the header points up.

s-dsc_0017.JPG

Solder the header.

s-dsc_0020.JPG

Next insert the LDR. For the LDR the orientation does not matter. For the phototransistor it does! The phototransistor has a long (emitter) and a short leg (collector). Insert it with the long leg at the bottom. And solder it.

t-dsc_0021.JPG t-dsc_0022.JPG

Now prepare the LED. Mine are clear and have a lens on top. Use sandpaper to roughen the surface. That way the light of the LED will be emitted in all directions.

s-dsc_0023.JPG

The RGB-LED has four pins. Mine is a common cathode.

  1. green (short)
  2. blue (longer)
  3. GND (longest)
  4. red (shortest)

Bend the two inner legs a bit off.
s-dsc_0024.JPG

Insert the LED. Be sure to have pin 1 in the hole with the square solder pad. The longest leg is in the diagonal opposite corner. Now solder it.

s-dsc_0025.JPG

Now it should look like this and we are almost done.

s-dsc_0026.JPG

Drill a 4mm hole in the ping pong ball. Use a file to widen the hole a bit. Try to put it on the LED.

Program the controller and insert it into the socket. Take care of the notch.

s-dsc_0027.JPG

Here is the final result, the first firefly. Ready for some action.

Issues

There are minor issues that I want to have fixed for the next batch of PCBs.

  • I will make the PCB a bit larger to make it more stable.
  • The circuit is missing bypass capacitors (100nF and 100uF). It works great without but it’s best practice to have them.
  • The sockets for the power supply are not protected against polarity reversal. Not quite sure how to fix this.

Conclusion

Firefly

Playing with these fireflies is really mesmerizing. It’s not like most computer controlled things because it is non deterministic. Every time you start it, it will produce new patterns and behave differently.

I am quite happy how well the PCB worked out. It was my second design that I have had produced. Now I am feeling confident enough to go for a bigger batch of PCBs.

Downloads and Links

53 thoughts on “Synchronizing Fireflies NG

  1. Pingback: projects » RGB Firefly Sync

  2. we have been trying to buid this circuit at school and have run into problems trying to load the program onto the chip. We bought AT tiny13V 10 PU chips to use and are using AVR studio to load the program. Whenever we try to open the program using AVR it says the file size exceeds the memory size of the chip. Any help??

    Like

  3. Hi Matt,
    I haven’t tried AVR studio. Please check which version of gcc it is using. Most of the time gcc version 3 makes smaller binaries than version 4.
    Cheers,
    Alex

    Like

Comments are closed.