I’ve made plenty of LED Throwies in my day but I only recently discovered Karl Lunt’s low power LED firefly project. I was immediately inspired to make my own LEDfireflies. Unlike LED Throwies which will only last 4 or 5 days per battery, these LEDfireflies utilize ATTiny AVR microcontrollers and the LED as a light sensor (cool!) to get several weeks of flashing on a single battery.


LEDs are commonly used as lights (they are diodes tuned specifically to emit light and packaged in translucent enclosures) but they can also be used as photodiodes to detect light. If you have an Arduino kicking around, you can easily experiment with this concept. Check out Zorink’s Instructable for a step-by-step and also Mike Cook’s page for more info and a video demo.

This LEDfirefly project has a very short materials list which means you can build them for under $2USD per firefly though you will need to invest in an AVR programmer ($22USD) and will need some basic electronics tools.

Note: It’s possible to use an Arduino as an AVR Programmer though that’s outside of the scope of this tutorial.


  • ATTiny13A (Google)
  • 1 M ohm, 1/8-watt resistor (1/4-watt works too!) (eBay)
  • CR2032 Battery Holder (TNRBattery)
  • CR2032 Battery (Amazon)
  • Diffused LED (Amazon)


  • Soldering Iron and Solder
  • Helping Hand (Amazon)
  •  Needle Nose pliers
  • Small wire cutter
  • USBTinyISP AVR Programmer (Adafruit) (Note: This kit requires a USB cable USB 2.0 A-Male to B-Male Cable)
  • Board Vice (Amazon) (optional but helpful for assembling the USBTinyISP)
  • Solder Sucker (Amazon) (optional but helpful for assembling the USBTinyISP)
  • Jumper Wires (Amazon)
  • Breadboard (Amazon)

Programming the ATTiny

The following tutorial was created on a Mac running OSX 10.8. However, you can also accomplish everything under Linux or even Windows.

1. First you’ll need to assemble the USBTinyISP Programmer. This is what you’ll use to speak with and upload files from your computer to the AVR microcontroller. LadyAda provides detailed instructions for how to do this. Note: when you’re installing the resistors to the board that you should use jumper wires (instead of of the supplied resistors) for R4 and R7.

2. Once you’ve assembled the USBTinyISP Programmer, you’ll need to download and install the CrossPack development environment for Atmel’s AVR microcontrollers. If you’re running Linux, refer to Lady Ada’s AVR Tutorial and if you’re using Windows, check out AVR Studio.

3. Connect the programmer to your computer via USB and open a terminal window (Applications > Utilities > Terminal). Test the interface to see if the programmer is recognized by entering the following command:

avrdude -p attiny13 -c usbtiny -n

It should send back the following message:

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override this check.
avrdude done. Thank you.

This confirms that your computer is connected to and recognizes the USBTinyISP Programmer. If you’re on a Mac, the green LED light on your programmer will now likely be illuminated. Cool!

Note: If your test instead sends back:

avrdude: Error: Could not find USBtiny device

You should double check your USB connection and try changing USB ports and running the test again. You might also double check your soldering work and make sure you put all of the components in the right places. If you’re still having trouble after that, spend some time on the Adafruit forum and, if necessary, with your favorite search engine.

 4. Once you’ve confirmed that your computer can connect to and recognize the USBTinyISP Programmer, the next step is to wire up the microcontroller on your breadboard. I’ve created a diagram to help illustrate how to wire up the pins correctly.

Note: This illustration is created from a bird’s eye view and assumes that the “holes” on the USBTinyISB 6-pin connector and the “legs” of the microcontroller are all facing down towards the table.


When you’re finished wiring everything up, it should look like this (right side of breadboard).


Note: I’ve built several LEDfireflies and have hacked together a small cable connector jig to simplify the process (see left side of breadboard on photo above). This allows me to quickly plug in the 6-pin USBTinyISP cable to my breadboard without fumbling with the jumper wires each time.

5. Now you’re ready to program the chip. First let’s run a test to make sure your computer can communicate with the microcontroller. Open up your terminal and enter:

avrdude -p attiny13 -c usbtiny -n

It should return the following message:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9007
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

If you instead get an error message, check your connections (the breadboard wiring can be confusing and you may have done it backwards). When you get stuck, refer to the Adafruit forum and the Internet for help.

Next, you’ll need to download a copy of Karl Lunt’s code (mirror) to flash the microcontroller. Note that the zip file includes the C source file and a .hex file. Unzip the folder and place it somewhere convenient like your desktop. Then inside the terminal, change to the correct directory:

cd Desktop/fireflyLED

Now upload the .hex file to the microcontroller:

avrdude -p attiny13 -c usbtiny -U flash:w:fireflyLED.hex:i

It should send back a success message. Cool!

Assemble the LEDfirefly

Now that you’ve successfully programmed the ATTiny microcontroller, you can begin to build your LEDfirefly. Here’s a bird’s eye view wiring diagram of an assembled LEDfirefly.


1. Take your LED and gently pry the two leads (legs) apart as if you were going to create the letter A. Now wrap one of the leads from the 1 M ohm, 1/8-watt resistor around one of the leads of the LED (about 1cm down from the glass base of the LED). Then wrap the second resistor lead around the second LED lead.


Note: It doesn’t matter which lead connects to which – these resistors work in either direction.

Also note: The shorter lead of the LED is negative. I recommend marking the negative lead with a sharpie (near where it meets the glass base) so that you can identify it later.

2. Now solder the resistor to the LED.

3. Once you’ve finished, you can cut the LED leads short (be sure to leave the leads from the resistor uncut). Now take the negative lead and attach it to the ground pin on the ATTiny13A. Then take the positive lead and solder it to the pin beside the ground.


4. Now that the LED and resistor are soldered to the ATTiny13A, the last step is to connect them to the battery holder. Flip the battery holder upside down and position the ATTiny13A on top so that it’s ground pin is closest to the negative terminal on the battery. Solder a short jumper wire from the ground pin of the ATTiny13A to the negative terminal on the battery holder.

5. Finally, solder a short jumper wire from the VCC pin of the ATTiny13A to the positive terminal of the battery holder.

6. Insert the CR2032 battery into the battery holder.

Note: The “+” and text on the battery should face outwards so that you can see them.

 7. The LED should now start flashing. If you place the LED directly under a strong light (or in direct sunlight) it will stop flashing.


Once you’ve successfully built your LEDfirefly, the next step is figuring out what to do with it. Assuming you plan to install it outdoors, you’ll want to weatherproof the electronics in some way. While the possibilities are endless, a simple solution is to place the LEDfirefly in a zip lock bag. However, I’ve found that a more elegant approach is to place my LEDfireflies in small translucent takeaway sauce containers.


If you drill a hole in the container lid, you can carefully pop the LED through the top while keeping the electronics sealed inside. LED.firefly.enclosure

I also like to place a 1/2″ rare earth magnet in the bottom of the container as it allows me to easily throw and attach the LEDfirefly to any ferromagnetic surface.



Also read...


  1. Pingback: Online activist, programmer Swartz dies in N.Y. - ALIPAC

  2. Pingback: bigOfeature » Blog Archive » WE ARE ALL AARON SWARTZ

  3. Pingback: Enlaces compartidos

  4. Pingback: ¿La página de aterrizaje de tu PirateBox en tu idioma?

  5. Pingback: Gemischtwarenladen #4 « jfml/blog – illustration, design etc.

  6. Pingback: Un réseau alternatif à Internet voit le jour | Blogue

  7. Pingback: PirateBox by David Darts

  8. Pingback: Apollo-NG - Argus

  9. Pingback: Sneakernets and Un-clouding your files | No Fun Robot and Pandabrarian Explore Libraries

  10. Pingback: « Pirate box »: un réseau alternatif à Internet voit le jour à Clermont-Ferrand | ELISHEAN

  11. Pingback: PirateBox DIY – OpenWrt by David Darts

  12. Pingback: Bau die bubble | Pearltrees

  13. Pingback: Piratebox : partager ses fichiers avec son entourage sans Internet

  14. Pingback: Distributed Networking | Pearltrees

  15. Pingback: PirateBox usa Raspberry Pi para Compartilhar Arquivos e criar Chat Anônimo | Raspberry Pi Brasil

  16. Pingback: my 2013 bcla conference experience | librarianaut

  17. Pingback: Cheap wireless hacking with OpenWRT | Tap5

  18. Pingback: Halk Hareketlerinde Bilişim Teknolojisinin Kullanımı Üzerine Notlar | İbrahim Filazi Kişisel Web Sitesi

  19. Pingback: Piratebox – some notes | merglindev

  20. Pingback: LEDfirefly | Digital Electronics & DIY | Sc...

  21. Pingback: LEDfirefly | RaspberryPI | Scoop.it

  22. Pingback: PirateBox DIY - OpenWrt | morezane | Scoop.it

  23. Pingback: LED Fireflies are the new LED Throwie - Hackalizer

  24. Pingback: Is the Next Direction of Online Education…Offline? « Saylor.org – Free Online Courses Built by Professors

  25. Pingback: PiratenBox Teil2 | Notizen

  26. Pingback: Atlantide Box | litteraturing

  27. Pingback: Cheap alternative to WIFI USB Dongle for Sony Bravia | My two cents

  28. Pingback: PirateBox – some tipps | cd /home/ && cal

  29. Pingback: PirateBox – some tipps | cd /home/ && cal

  30. Pingback: John McAfee takes on the NSA with secure anonymity device | NEWS ONLINE

  31. Pingback: John McAfee takes on the NSA with secure anonymity device

  32. Pingback: John McAfee takes on the NSA with secure anonymity device «

  33. Pingback: Yebaa.com | John McAfee takes on the NSA with secure anonymity device

  34. Pingback: rushengine.com | John McAfee takes on the NSA with secure anonymity device

  35. Pingback: John McAfee takes on the NSA with secure anonymity device | Eric Hazelton

  36. Pingback: John McAfee takes on the NSA with secure anonymity device

  37. Pingback: Wie kann die Piratebox unter OpenWrt auf einem TP-Link TL-WR703N Router installiert werden? | Wenzlaff.de: Rund um die Programmierung

  38. Pingback: John McAfee takes on the NSA with secure anonymity device | Tech gadgets help

  39. Pingback: John McAfee takes on the NSA with secure anonymity device | e-Trader | Free Classifiedse-Trader | Free Classifieds

  40. Pingback: Foiling spooks: Mr McAfee's little black box

  41. Pingback: Piratebox | commandlinepunk.org

  42. Pingback: your friendly neighbourhood wretched hive of scum & villainy – a presentation | librarianaut

  43. Pingback: geek up your life » Condividere files in pubblico con una PirateBox

  44. Pingback: The Piratebox | Malwarebytes Unpacked

  45. Pingback: Raspberry Pi | Pearltrees

  46. Pingback: PirateBox DIY | Gamer GeekGamer Geek

  47. Pingback: Pirate Box test | Gamer GeekGamer Geek

  48. Pingback: Connecting people in remote areas - with a Pi - Raspberry Pi Projects

  49. Pingback: Piratebox « NESIT Hackerspace

  50. Pingback: Condividiamo la conoscenza – costruiamo una BiblioBox | Michele Maffucci

  51. Pingback: Condividiamo la conoscenza – costruiamo una BiblioBox | Michele Maffucci

  52. Pingback: Luciole numérique | EIRL Marc Sibert Consulting & Dispositifs

  53. Pingback: Luciole numérique | EIRL Marc Sibert Consulting & Dispositifs

  54. Pingback: PirateBox, una caja para el que sabe que compartir no es robar | eulaliobe

  55. Pingback: « Pirate box »: un réseau alternatif à Internet voit le jour à Clermont-Ferrand

  56. Pingback: PirateBox DIY | Era digital | Scoop.it

Leave a Reply