Arduino Fireflies

One of the things I look forward to with summers in Pennsylvania are fireflies in my backyard. I recently taught myself Adruino programming for the purpose of making this simple project. It’s a great program to start with and is easy enough for any programmer, novice to expert, to build, modify and have fun with in only a few minutes. Let’s get started.

Step 1: What You’ll Need.

To get your bugs blinking, you’ll need these components:

  • Arduino. I started with the Nano, however any Arduino compatible micro-controller will do.
  • Yellow LEDs, 5mm. You can use up to 6 of them.
  • Resistors. You will need one resistor per LED to limit current. I used 470-ohm but anything above 150 ohms should be fine to protect your micro-controller.
  • Breadboard.
  • Jumper wire.

To complete the project for your backyard, you’ll need:

  • Weather proof project box.
  • 9-volt battery with a connector. (Please see notes at the bottom of this section.)
  • Switch. (I chose these waterproof switches. If you are not using this outside, any switch will do.)
  • A few yards of wire to place the LEDs around the garden. I used about 10 feet of Cat5 Ethernet wire per LED.
  • A small breadboard or some perf board.
  • A weather proof cable gland through which the LED wires run. (You can omit this if you are not using this outside as well.)
  • Heat shrink tubing to protect your LED bug butts.
  • Green hook-and-loop (i.e. velcro) strips to affix the LED fireflies to plants and posts in your garden.
  • Male headers for plugging components into your small breadboard.


  • Drill bits for the project box. (Use this opportunity to get yourself a nice step-bit. You’ll be glad you did).
  • Hot glue gun.
  • Soldering iron.
  • Rotary tool (i.e. Dremel) for carving out space in the project box if you need it.

A Few Notes Here:

1. The battery choice was for a quick and easy start-up. Using a 9-volt battery permanently is a bit wasteful. You’re better off using a 4x AA-battery holder for longer life (however you will need a bigger project box in which to fit it).

2. If you choose to deconstruct a Cat 5 Ethernet cable for the wires, make sure they are copper core and wrap them neatly around some PVC to keep them organized while you work. Again, I used about 10 feet of wire per LED. If you want to spread the lights out far and wide, by all means use longer wires!

3. Lastly, all the links I provided are mere suggestions. Please read through this entire Instructable before building or buying anything as you will gain a better understanding of how you would like to personally proceed.

Step 2: Build the Circuit.

This project uses the pulse width modulation pins on your Arduino. The micro-controller has 6 of these pins and you are welcome to use as many as you want. The circuit is pretty straight forward. Wire all power from the pulse width modulation (PWM) pins D3, D5, D6, D9, D10, and D11 to the positive ends of your LEDs. Wire the negative ends to the resistors and then to a common ground. (The resistors can go in front of or behind the LED. It makes no difference unless you want to safeguard against short circuits in higher currents.) I included a few schematics to help with wiring. (The diagrams where created using Fritzing design software.)

Step 3: The Code.

If you are a seasoned programmer, you’ll find this code simplistic. It is a great code to start learning with as it introduces you to the use of variables, pinmodes, functions and even a random generator. The code is not as compact as it can be as I am sure the same effect can be achieved with arrays etc.

The code comments lay out the logic of each section. The entire code is embedded here and you may download the sketch below.

Read more: Arduino Fireflies

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top