Programmable LED Firefly Jar

49K47436

Intro: Programmable LED Firefly Jar

This is a fun, beautiful and inexpensive project that makes a great gift! I first started making these over a year ago and my original prototype (and many others) are still running strong.

Building a firefly jar only requires an hour or two of your time, and ever the fan of creative re-use, many of the parts can be recycled from old electronics and things around the house.

To do this project it's helpful to have some Arduino and soldering experience.


Hardware:

* an ATTiny85 (ATTiny85-20PU, or tiny-based board, like Trinket)
* Some addressable LED pixels (I'm using these, but there are

many possibilities.

)
* 1 .10uF capacitor

* low value resistor (100, 220, 470 Ohm worked fine)
* a piece of perf board or a PCB
* a 5V wall wart (old cell phone power supplies!)
* a mason jar (used pickle / spaghetti sauce / mason jars)
* diffusive material (Used shipping materials: bubble wrap, tissue paper. Paint, glass frosting, possibilities are endless)
* An AVR programmer (like the USP Tiny ISP)
* breadboard and soldering supplies are helpful!

Software:

* Arduino
* Tiny core
* Adafruit NeoPixel (or FastLED) library

This Instructable shares some things in common with my other one written about ATtiny -- if you want a more in-depth primer on using this small microcontroller with addressable LEDs read that one first!

If programming an ATtiny seems like too much you could make this project happen with something small like (ATtiny85-based) DigiSpark or Trinket.

Update: I created a repository for firefly jar code and schematics.

STEP 1: Setup Your Software

1. Download and Install Arduino

2. Download and install the Tiny Core (instructions), you need ATTiny85 8Mhz or 16Mhz support!

3. Download and install the NeoPixel library (Copy it to your Arduino sketches folder /libraries/)

STEP 2: Program and Test Your ATTiny

Setup your ATTiny on a breadboard.

Wire your ATTiny to the programmer as shown in the schematic. Note the dot on the IC, this is pin 1!

In Arduino choose the example sketch from the NeoPixel library > standtest.

Change the initialization

Determine the number of pixels you are using and change the data pin to 4

Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, 4, NEO_GRB + NEO_KHZ800);

Upload and test

With ATTiny85 8Mhz or 16Mhz (Internal Osc) selected in Tools -> Board, test and upload your sketch! If it doesn't work immediately you most likely need to set the fuses on the ATtiny. You'll only have to do this once per microcontroler, with the 8 or 16MHz option set, choose 'Burn Bootloader' option in Tools, then try uploading your sketch again.

Create patterns

Create your own patterns to run on your firefly jar!

Schematic from Fritzing via harizanov

STEP 3: Prepare the Jar & Adapter

Cut off the connector end of your old power adapter, separate and strip the red and black wires. Test the voltage and polarity with your multimeter.

Poke a hole in your jar lid with a nail or sharp object (careful!) and thread the cord through.

For strain-relief you can tie the cord in a knot.

STEP 4: Solder Your ATTiny and Components

Solder your ATTiny to a piece of perfboard. Include a decoupling capacitor across the power supply and a small value resistor. If you want your install to be more flexible install a 8-pin DIP socket so you can remove and reprogram the microcontroller later.

Attach the your power and ground lines you threaded through the jar lid to this circuit.

STEP 5: Assemble Your Jar

Assemble your jar and distribute your LED pixels evenly.

I've found filling it with packing peanuts, bubble wrap, tissue and scrap paper works very nicely and creates some interesting effects. Reflective plastics and broken glass can also be fun.

If you're feeling very ambitious you can glaze the jar or buy some paint and use that to give it a more translucent look.

Plug your jar in and enjoy the beautiful patterns!

STEP 6: Bonus: Make It a Touch Lamp!


And that's not all... bonus round :)

Using the Capacitive Sensor library and two pins on your microcontroller you can make your jar a touch lamp.

There are a few extra requirements to do this, mainly your jar will need a metal lid (or a piece of metal underneath your lid), and you'll need to connect two wires to either side of that lid (screws work well as an attachment point).

Getting this to work may involve a little trial and error on your part, some lids are coated, so you may have to do some sanding to get a good electrical connection, but it's an awesome effect.

Hardware:

* two screws or something metal to attach wires to a jar lid

* two more pins on your ATtiny

* 1 high value resistor -- 1M Ohm or greater to place on the output pin

* 1 resistor with a value of 1000Ohm or so to help protect the input pin from static electricity.

Software:

* Capacitive Sensor Library (learn more about how it works)

* Adafruit Neopixel

Here is one example sketch for touch. Some tweaking of TOUCH_THRESH and TOUCH_DELAY may need to be done to work with the particulars of your jar.

STEP 7: Bonus: Use a Printed PCB!

I wanted to make these as holiday gifts for friends and family and did not want to do all of that soldering to perf-board. So I made a simple PCB to ease my construction process.

I added a diode to prevent reverse power hookups and programming headers so you can change the ATtiny code right on the board.

I have a prototype using this PCB that has been running every day for nearly a year now and these jars have survived falls, kids, animals, burning man ---- and keep on running!

If you would like to use my PCB, you can order sets of 3 via OSH Park. I welcome collaborations and improvements to this board. If you're looking for a single board or kits, get in touch, if there's enough interest I'll do a run of them! If you hold a workshop to build these or make a cool variation on this design I'd love to hear about it.

33 Comments

A sandblasted mason jar would probably work great if you or someone you know have the equipment.
I'm thinking of making one of these with a wood base as a night light for my niece.
I really like the idea of having a PCB house professionally make the boards. They are so cheap to get 3-5 made, you could easily make them for gifts.
Hi!
I'm building one at this moment, but I'm getting a bit different colours.
Are your ws2811s RGBW or RGB?

I'm having a little trouble with this and was wondering if someone can help me out. My LED's came in a strip of about 50. Would i simply just cut them in 4 or 5 to fit into the Jar? Also, Each LED has two ends to it (6 wires). I understand 1 goes to VCC, 1 to GND, and another to pin 4. Where do the other 3 go to? Same place? Can someone draw up a little bit of a detailed schematic to help me out? Thank you. I appreciate it.

Yes, you can cut them at whatever length you'd like!

Look for the arrow on your led pixels or strip, it should point AWAY from your microcontroller. The three 'outgoing' wires at the end will remain unconnected (you can cap them or just clip them so they're sheathed).

Let me know if you have any other questions!

Thank you so much! I'll give it a try soon.

Would it be possible to build this on an Arduino. or a small Arduino like the Digistump? That would be a lot easier for a lot of us. No need for an extra programming device. It would get a lot bigger and wouldn't fit into a jar anymore.

Absolutely! Trinket, Gemma, Digispark are all ATtiny based and will work. Arduino & variants are fine too.

Instead of a wall wart can I run this off of a DC power source? Say a 9 Volt battery? With a 4 Volt ? Watt resister???

You can totally run it off of a battery. You could use a 9v with a step-down or voltage regulator, I'd recommend hiding some AAs or lithium ion or a USB battery pack inside.

If you're using the touch sensor function on a battery read the notes on grounding here: http://playground.arduino.cc/Main/CapacitiveSensor

Fantastic!!! I'm on a tight budget. If I used AAs would 3 at 4.5 volt total work? would I need to adjust anything on the curcit board? or 2 3v hearing aid batteries at a 6v total?

One last question. Thanks so much for the help. This is my first project of this type. I ordered the PCB chips, and I was wondering what specific diode you used.
Thanks!

I used a Schottky Diode (1N5819) as it has a lower voltage drop, but a 1N4001 would work fine too. My jars only use 5 lights, if yours use more you'll probably want to find a diode rated for more current. You can also bridge the diode area with a wire, but only do that if it's going to be used somewhere where folks won't accidentally reverse polarity.

The lights and micro-control should work fine at 4.5V -- I think I've run them as low as 3.3V. 6V is probably a tad too much.

With batteries, one thing to watch for: when you program your ATtiny, choose an 8Mhz board/fuse settings, the 16Mhz setting has brown-out detection that's set at 4.3v!

was wondering if there is a way to 'string' them together and hang them in trees in the yard for outdoor evening lighting?

That's a great idea, I think there are a bunch of different ways you might do this:

Have a single controller somewhere and connect your jars in a series --- you'd string non-lighted power, gnd and signal lines between each. Or if you don't have too many jars you could run multiple signal lines in parallel from your controller.

Or you could make each jar independent and use some kind of sensor to vary the output, maybe based upon movement, or light, or the environment.

If you build something like this please share it!

Hey, thank you for sharing this, very cool, and I love how it uses ATtiny as well! I was just starting to experiment with LEDs at the time this was written, it's neat to see how components have evolved.

This makes me want to make a pattern modeled on firefly behavior, or create a collection of jar lamps here on Instructables (I know this has a long tradition in electronics)!

How much did the PCBs cost?

More Comments