This project uses green surface-mount LED's along with an AVR ATTiny45 microcontroller to simulate the behavior of fireflies in a jar.

(note: the firefly behavior in this video has been greatly sped up in order to be easier to represent in a short film. The default behavior has significantly more variance in its brightness and delay between plays.)

Step 1: About This Project

The inspiration for this project comes from having never lived in an area where fireflies were common and being deeply fascinated whenever I encounter them in my travels.

The flash patterns have been digitized from firefly behavioral research data found online and were modeled in Mathematica so that variations of speed and intensity could be generated. The final output was transformed by a lightness function and written into header files as 8-bit PWM data.

The software is written in avr-gcc C and source code is provided along with a pre-compiled .hex for convenience. The code has been significantly optimized for efficiency and to minimize power consumption. Crude runtime estimates predict a 600mAh 3V CR2450 battery should last between 4 to 10 months, depending on the song pattern used. RIght now the source comes with two patterns, song1 and song2, with song2 as default. Song2's estimated runtime is 2 months, song1's is 5 months.

This project involves a fair amount of surface-mount level soldering. However the circuit design is trivial and the fact that we're able to use an off-the-shelf SMD prototyping board rather than having a custom PCB made greatly saves on cost. It would be very simple to create a non-surface mount version using the PDIP version of the ATTiny45 and through-hole LED's.

The cost of the electronic components comes in at around $10-$15 (after shipping) or so and assembly time is on the order of 2 hours.
<p>Does anyone sell the board premade with the strings of lights? I can slap on a battery holder and a mason jar and lid but I'm new to electronics still. </p>
<p>I loved this so much I made it and created a little pcb for it. V2 will have touch sensors and ability to utilize a full battery down to .9v. </p><p>You can get V1 PCB here:</p><p>https://www.tindie.com/products/gilmanb/firefly-jar-kit-or-fully-assembled-/</p><p><a href="https://www.tindie.com/products/gilmanb/firefly-jar-kit-or-fully-assembled-/" rel="nofollow">https://www.tindie.com/products/gilmanb/firefly-ja...</a></p>
<p>This looks great! I bet the CR123A really gives you a longer battery life.</p>
Totally! Hey, I have some questions about your code. Are you ok talking over email? Specifically the assembler for pwm and whether you'd be interested in helping me port the code to psoc4?<br><br>Thanks!!<br><br>Brian
<p>Please save my sanity and tell me how I get the code into my arduino sketchbook. After much trial and error I have been able to download the basic &quot;blink&quot; code using the sparkfun progranmmer into my AtTiny45 but how do I get &quot;firefly.tgz&quot; downloaded. Arduino will not accept this suffix. What am I missing?</p>
<p>Nice project</p>
<p>Has anyone tried to make this with an Arduino?</p><p>I have digispark (<a rel="nofollow">http://digistump.com/products/1) </a> and a LED Charlieplex Shield (<a rel="nofollow">http://digistump.com/products/13) </a> lying around. driving 20 fireflies with one board would make an impressive lightshow.</p><p>Or are there more PWM ports needed?</p>
<p>I successfully used an Arduino Duemilanove; the Arduino Uno is not compatible (I had to trade the Uno with my brother to get his Duemilanove); the project was two years ago and I can't for the life of me remember why it wouldn't work, I'm not very tech-savvy. </p><p>I ended up making 10 jars in a matter of about two weeks for Christmas; it's a very time consuming, painful and rewarding project. Everyone seems to cherish them. Last night I swapped out the 3V battery holder for a USB connection. </p><p>I gave up trying to figure out if I needed a voltage <br>regulator (5V to 3V); 500mA max output from USB, and just soldered it on <br>because I have a death wish or something. In either case, I&rsquo;ve had it on for a <br>day now constantly; hasn&rsquo;t blown, doesn&rsquo;t overheat. I measured the amperage at <br>each leg; it&rsquo;s under the 20mA limit of the LED&hellip; not sure how the ATTINY45 ended <br>up managing that, but it did.</p><p>If anyone&rsquo;s interested, you take a USB cable, chop off one <br>end, expose the wires (should be red/black/white/green) connect RED +, BLACK -, <br>white and green are for data; just cut them back and they are not used. <br>Shielding and mesh can be twisted together and soldered under the lid (scrape <br>away any paint on the mason lid to expose the metal surface or just fry it to <br>death with some solder till it melts). </p><p>I drilled a 3/8&rdquo; hole in the lid and used a 3/8&rdquo; plastic <br>grommet to protect the cable going into the jar and keep it stationary.</p><p>~Fin. </p>
This project took me WEEKS to figure out (mostly in terms of programming the ATTINY45 &amp; the fact I've barely soldered before, let alone micro LED's and hair-thin wire), in the end I will make eight jars for this holiday season, I've completed three so far. This is an excellent instructable!!!
I feel like we may have jumped into the same boat. I was wondering if you could tell me what you used to program the chip? I am looking at the Pomona 5250 clip but I'm not sure what I'm supposed to be plugging that into?
<p>Very sorry for the year late reply; I haven't been on instructables for a while apparently. :) IF it is still of any interest, I used an Arduino Duemilanove, for which your Pomona 5250 clip will work perfectly well. I had to literally solder each chip to a spare board with jumpers soldered to it, jam it into the Arduino to program and unsolder the chip/resolder it onto a finished board. :) I had a time constraint and I couldn't get the clip in time and was too stupid to buy a DIP socket solder tail :)</p><p>Last night I took my 2 year old jar and modded it with a USB connection. It's really a great project. :)</p>
Do you randomly select the wires to be joined into two wire bundles? Or do you want one wire from the three wire bundle connected to Pin A and one from the three wire bundle connected to Pin B? Or is there some other scheme?
<p>No, it cannot be random. This caught me up also, you really have to wire it exactly as the schematic describes or it won't work. You can read the specifics above, but basically:</p><p>PIN_A and PIN_B must each have three LEDs attached to them on the anode/positive side, so you have 2 &quot;bundles&quot; of LEDs, each with 3 LEDs.</p><p>PIN_C, PIN_D, and PIN_E must each have one LED from the PIN_A bundle, and one LED from the PIN_B bundle attached to them on the cathode/negative side.</p>
Hi, Could you perhaps furnish your Mathematica notebook that you used for formulating the lookup tables?
I've tried using ten strings and the 4 LEDs on pins E and D stay on constantly until the main ones driven from A and B are turned on. Any ideas on the issue?
Fantastic ible -- I'm just now soldering some 0603 leds to magnet wire myself - its a nightmare! <br>My method of choice is based on this ible - mount led in tweezers, mount tweezers in clamping helping hands, but I hand-hold the magnet wire. by resting my hand mid-knuckle on the brace of the clamp, I can use just one knuckle of articulation to adjust the wire. I found it easier than manipulating a helping hand clamp with the wire mounted in it. Loosely free-handing the wire is near impossible while also wielding the soldering iron. <br> <br>Do you do anything special to insulate the bare ends of the leds? I'm thinking clear enamel or conformal coating to add some robustness.
I'm having the same troubles as Anders, I would like to reduce the time between each pause. Can anyone help? I'm comfortable making changes to the source code and making a new .hex file, I'm just not sure what needs to be changed. If someone would please help me out I would be willing to share the source and .hex files for everyone else.
Horrible late :) <br> <br>But i have done one now and it seems like its a big pause, about 30 seconds sometimes, can i shorten that? or can anyone good with codes send me a update? <br> <br>otherwise it works perfectly.. after that intense soldering, my god, it was a job for the hubble.. tel... microscope :)
Hi! <br>i'm doing a couple of jars for my balcony, i bought enough components for 10, so I did a trial run, and soldered everything on, programmed the attiny and just going to test it with one led, so i attached the batterypack and the led is lighting up, but its just on and off, no fading at all. <br> <br>What could be the problem? <br>
I have a couple of these boards for sale. ATTiny45 is per-programmed with the provided script. Email bgrablin at gmail.com, if anyone is interested.
Awesome project. I intend on building this at some point. Probably using thru-hole chip and resistors, but thats based on my preception of my solder skills. Any way, power! I've been looking for a use for those self charging luminares they sell to line driveways and the like. Basically, it's a solar cell mounted on a pole with an LED and a rechargeable AA or two below. I've seen them for 8.00 USD at wal-mart and the like. Seems you might be able to tap its charger circuit for on/off detection too.
That is a good idea- the only problem you're going to run into is power (or more specifically, a lack thereof). Those things usually only run on a single 1.5V (or less) "AA" which between the uC and all the LEDs probably won't be quite enough voltage. You certainly could make it work, but you would have to mess around with the circuit some, and might just be better off buying a solar cell and rechargeable battery to run it all. Something on the order of ~3V should be sufficient (that's what mine uses). HTH- Michael
You will need a simple boot regulator Polou has a 1.5 to 5V assembly for $5.45 http://www.pololu.com/catalog/product/798 It will supply enough current for this project. You could build it up from the NCP1402 for less but the Pololu board is so small and convent. I have used these for some LED projects and am seriously thinking of building a solar version of this project with the Polou board and a salvaged solar cell.
I realize I'm replying to an ancient thread (and the original questioner is long gone), but this is a very popular instructable. <br><br>The Polou boost circuit is a great suggestion. It is small, very efficient, and low cost. <br><br>An alternative (lower cost) idea is to use a MAX756. Should be noted though, in QTY 1 a max756 is almost $5, but Maxim is very liberal with free samples (I even put &quot;Hobbyist&quot; in as my company name, though I did use a business email address). An advantage is the 756 can be configured for 3V so you can use smaller resistors and power lasts longer.<br><br>But it may be easier to get the solar charger to charge 2 batteries...
I had an awesome time making these as a wedding decoration and put together a custom firefly PCB. You can check it out here:<br><br>https://www.instructables.com/id/Wedding-Firefly-Fishing-Floats/<br><br>Thanks Keso!<br><br>-Nick
Great project. Anyone willing to make me 2 and get paid ? I have an upset girlfriend (love of my life) . Sounds silly but little things arem what make her happy. Favorite new song The Band Perry All Your Life refrences catching fireflies. Anyway. I want to do something really special for her and I'm afraid it will take me a couple weeks to get parts and assemble. <br> <br>Don't want to sound desperate but I am. I relly love her and would like to give her a jar of sand from the edge of the ocean and a jar of firelies : ) <br> <br>I'll pay any fair price if someone has one made or would be willing to make. <br> <br>Thanks in advance to all <br>Mike ueiservice@yahoo.com
I FINALLY got this to work :)<br><br>Thanks so much for this instructable. It was a lot of fun to build and very rewarding once I got it to work.<br><br>If anyone needs help with the programming feel free to contact me
I guess I am more novice than I thought... How do you insert this source code? I've never worked with programmable ICs before. Great project! It will make for a great gift, and maybe start an interest in tech for my kids/nephews!
you need a programmer (for example avr dragon)<br><br>https://www.instructables.com/id/Help%3a-An-Absolute-Beginner-s-Guide-to-8-Bit-AVR-Pr/
Most everywhere is backordered on ATTINY45V-10SU-ND. Would any of the ATTiny45V's work?
Any ATtiny45 should work, but if you want to use the same proto board it needs to be SOIC form factor. You can also use an ATtiny85, there is no difference except it has double the flash memory.
This is by far the best instructable I've had the pleasure read. I built one based on your excellent and detailed instructions however, I've got several days spent on crash course researching how to program! I think I've installed just about every programming software available and yet I still can't figure out how to transfer the program code you supplied into any of the programs I have installed! Is Vista the issue or am I just not understanding something?!! I'd love it if someone could shine some light on this for me!
Yay! I got it to work!
HOW!?!?!?!?! I still can't get it to work. What program did you used and what Programmer? My computers are running XP Pro, and I've got the Pocket AVR Programmer (http://www.sparkfun.com/commerce/product_info.php?products_id=9825) from Sparkfun.com Thanks ~Corry
This thing works great, one silly question. How do I make it use song one instead of song 2?
could one easily switch out the battery with a solar panel? if so, could you recommend any parts? i just think it'd be great if it we could leave it on a window sill and have it turn on and faded out every evening
I was gonna use a cheap solar light, take out the solar cell, photo cell, and accompanying circuitry.
&nbsp;hey I'm looking to make one of these, but Digikey is out of the Microcontrollers you suggest. Would <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&amp;site=US&amp;WT.z_homepage_link=hp_go_button&amp;KeyWords=ATTINY45V-10SU-ND&amp;x=0&amp;y=0" rel="nofollow">this</a> one work instead of the ATTINY45V-10SU-ND? Could someone get back to me asap? I wanna make some of these for Christmas presents. Thanks! :)
Hi, Im not in the US and an unable to get the chip you have in your parts list. Would this work as a replacement ? http://www.mantech.co.za/ProductInfo.aspx?Item=128-8352 I have no programming or electronics experience so any help will be greatly appreciated Thanks
&nbsp;Yes, that chip should work fine
Great project. I can see building a few as gifts. For a solar powered version, why not hack one of the cheap ~$5 solar garden lamps? They have the solar cell, battery and circuitry inside. You could use that to power the Fireflies and sense light levels too. The guts should all fit nicely under the mason jar cap. The output of the solar lamp is usually pulsed, there is a circuit on the web to make it into a 5 volt supply.
i was thinking the same thing, i know this is an older post, but did you ever end up trying this out?
I'm trying to program the chip with the usbtiny from sparkfun and using programmers notepad, but it keeps coming up with &quot; &gt; &quot;make.exe&quot; program makefile:227: warning: overriding commands for target `.c.o' makefile:222: warning: ignoring old commands for target `.c.o' make.exe: *** No rule to make target `program'. Stop. &gt; Process Exit Code: 2 &gt; Time Taken: 00:01 &quot; I am new to programming and would appreciate any help, tryin to make this as a birthday present for my wife, if I get it working I'm gonna make three more for my nieces. Thanks ~Corry
Are you still offering the programmed chip kit? If you are I'd be interested in probably 4 preprogrammed chips. Thanks ~Corry
My favorite instructable so far! For our wedding, my&nbsp;Fianc&eacute;e&nbsp;and I purchased glass floats (<a href="http://www.coldwatercreek.com/products/Detail.aspx?productid=46494&amp;ensembleid=52597&amp;bpid=96&amp;ci_src=14110944&amp;ci_sku=015069392" rel="nofollow">see here</a>, did not pay that much though!) and I have 20 of them. I'd like to make 20 firefly glass floats as decorations, and I have a few questions. <br /> <br /> First, digikey does not have any tiny45s in a 9081 footprint, are there other similar chips I can use (I know I'd have to modify the code slightly). A second option that I'm seriously considering is to use expressPCB and make a custom board.&nbsp;<br /> <br /> Second, I only have a 1&quot; hole to insert my firefly leads through. I need to find a way to distribute them throughout the sphere. Anyone have any ideas besides using double sided tape?<br /> <br /> Thanks!<br /> Nick<br />
This is a great idea, but how do you get the floats open? Do you drill the top of them? What kind of bit?<br />
Great question, fortunately the floats come with a hole pre-drilled! It's actually an artifact of the glass-blowing process I think. There's probably a way to do it with a masonry or other abrasive bit. I've completed my first float, and have decided to custom print a pcb that will solder directly to the battery holders I've ordered. If anyone is interested I think I will have enough parts left over to offer a few &quot;kits&quot; with programmed chips (it will be a couple months before it's all said and done though). I'll also provide photos and video when I'm finished. Nick
I am thinking of doing this with the teen youth group. I will want some kits, if you are not asking to much for them. I am not ready to go teach myself basic programming yet, so this will be a big help in that direction.
1. Use an ATtiny85.&nbsp; It is pretty much identical, with twice the flash and only costs about 10% more ($2.15 instead of $1.94 in small quantities from digikey).&nbsp; You won't have to modify the code at all.<br /> <br />
very nice instructable, well explained and phgotographed

About This Instructable




More by Keso:Jar of Fireflies 
Add instructable to: