Start a swarm of these DIY Firefly LEDs a-blinking, and they'll create a random pattern and blink an angry red. But after a few minutes, thanks to some clever microcontroller code and a light sensor, they'll soon all be blinking in sync with a nice, calming blue color. It's a neat bit of DIY electronics that's elegant in its simplicity, and surprisingly cool to see in action on video. Even if you disturb their perfection with a flashlight, the system will eventually self-correct: The code works like this:
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.