There are plenty of candle-flicker LED projects out there, but I was looking for one that had a few additional properties:
- A more realistic flicker based on a normal distribution of light intensities instead of uniform random numbers
- A candle that would respond to the environment
- Something that fit in a standard Yankee Candle (R) tealight candle holder
The thing I created uses an ATTiny85 to generate a binomial distribution of random numbers that are then fed to a PWM output that drives the LED intensity. The LED is the Adafruit Sequin LED that is compact and comes with its own resistor for ease of use. I've added a light sensitive resistor that is connected to one of the analog inputs of the MCU, which triggers a change in the LED flickering when someone moves their hand over the object.
As an added bonus I connect the battery back (in the base) to the electronics (in the cap) through some copper tape along the inside of the candle, so it is possible to switch the thing on and off just by twisting the top.
I've made a video of the final thing in action and one more video that shows how the LED candles behave compared to a real tealight candle.
I realized when writing these instructions that there are a lot of little parts that make up what is really a simple design. In order to make this page tractable, I need to assume that you know how to program the ATTiny85. I have written a blog entry on my website describing how to do this with a Raspberry Pi. (Sort of, that is for the ATMega328p; I have the required modifications for the ATTiny in draft form.) I provide step by step instructions for the electronics build, because not many of us (myself included) are accustomed to building electronics in the absence of a protoboard.
Bill of Materials
*Most items were purchased either from Adafruit or Newark. Some were sitting around my house. The copper tape is from Electron Microscopy Sciences but I've seen it on Amazon.
- ATTiny85 (Newark part number 68T3808)
- 8 pin 0.3" socket (Adafruit Product ID 2309)
- CdS photocell (Newark SKU:95F9039, manufacturer: Excelitas Tech)
- Sequin LED (Adafruit Product ID 1758)
- 10k resistor
- 3 LR41 button batteries (stolen from my wife's laser pointer - don't tell)
- copper wire (18 gauge)
- magnet wire (0.6 mm diameter with insulation, ~ 23 AWG)
- soldering equipment
- wire clippers, needle nose pliers, razor blade.
You can find the MCU code for this project on my github page. I have included a makefile and shell script used to compile and burn the software using the Raspberry Pi. In order to keep this set of instructions from getting longer than it already is, I'll post more detailed instructions in the README file on the github page.
Hey, this is my first build! I purchased a MakerFarm kit in June of 2015 (and published this in mid July of the same year) and have been building and playing with my new toy since. I'm fairly confident that this is a build that beginners can do, since I'm a beginner and I just built it.
Because we will be soldering into the 3D printed object, using ABS is highly recommended. I used filament that changes color with temperatures, and it was fairly obvious that the plastic was getting warm. If you're quick and efficient with your soldering technique, you might be able to get away with PLA.
Printed the objects on a 8" i3v Prusa. While I provide an .STL with all of the objects on one platter, I printed them individually due to some thermal gradients on my heated bed that lead to warping. The cap does not require support material, although you'll have to scrape away the edges to make the LED sequin and photocell fit snugly. It is possible to combine the base and battery pack into one unit, although I found that this approach, while elegant, made it hard to solder the battery pack connectors.
- Print the parts
The cap will require a little bit of scraping. Use a hobby knife to clean out the LED and photocell compartments. The diffuser pin holes on my prints always sealed and needed to be opened as well.
- Set up the battery pack
Take two short pieces of copper wire and push them through the holes at each end of the pack. Use pliers to bend the wire around the pack, leaving a small extension to solder some magnet wire on to.
- Wire up the base
Cut two pieces of copper tape (~ 3 cm) long enough to start at the bottom of the base and climb up the entire wall. It is OK (preferred?) if the tape covers the lip as well. Position the tape such that the two pieces are at a 90 degree angle (12 o'clock and 3 o'clock). This prevents you from turning the cap in such a way as to reverse the polarity voltage going to your microprocessor. Scrape the insulation from some magnet wire and solder the battery pack pins to the two pieces of copper tape. Making this attachment at the bottom of the base is easiest, in my opinion. Add the batteries. It is not a good idea to solder the pieces together with the batteries in place, as you will very rapidly transfer heat to the batteries, possibly damaging them. Granted, I've done it, and survived, but I don't suggest it. Mark which piece of copper tape is positive (the one attached to the flat end of the batteries).
- Wire up the cap
This part is a bit challenging, and I am not going to claim that I have the best solution. Be patient, and feel free to go off script.
- Place pieces of copper tape such that they will contact the base. At this point, you should make sure that you can attach the cap to the base and rotate the cap enough to make/break the connection. It will be tight. Mark the piece of tape that is the positive lead. I like to put this lead close to the photocell.
- Solder magnet wire to the sequins (about 2 cm in length).
- Insert the LED and photocell into their respective places in the cap. I find it useful to put the (+) side of the LED closest to the photocell.
- Solder one leg of the photocell to the positive lead. Feel free to clip off any excess leg.
- Solder the 10kohm resistor to the other leg of the photocell. Try to solder as close to the cap as possible. Do not clip this leg short yet. Solder the other end of the resistor to the negative copper tape lead.
- Solder the negative lead of the LED to the negative copper tape lead.
- Gently bend the legs of the IC socket so that the are facing horizontal. We do this to get a little extra space between the IC and the battery pack; you'll find that they tend to hit one another.
- You will need four pieces of magnet wire with the ends stripped for this step. Solder these pieces of wire to the socket as shown in the picture for this thing.
- Lastly, we will connect the socket to the cap. Using the normal convention for pin numbering (left to right 1 to 4 on the bottom, then 5-8 right to left on the top in the image linked above), connect pin 4 to (+), pin 8 to (-), pin 7 to the leg of the photocell that is attached to the resistor and pin 5 to the positive end of the LED, which already has some magnet wire attached to it.
- Squeeze everything in to place and make sure that there are no pins touching the copper leads that shouldn't be touching them. Attach the cap to the base and watch your light flicker. Wave your hand in front of the photocell and giggle.
- The wick/diffuser has a few pinholes to keep it in place. Snip some short pieces of copper wire and push them through and into the holes on the cap. Your build is complete.
Suggestions for improvements
- The photocell code is currently written such that a change in value above a certain threshold will trigger the "wind" mode. When the room is dark, the flickering of the LED triggers this event, so it is difficult to get a steady flicker under low light conditions.
- I am most proud of the copper tape on/off switch, which I think will find its way into many of my future designs. That said, it is not terribly robust, and needs some refactoring.