DIY LED Candles - Page 1
Forum section: electronics / projects

author: kmm
author_rank: Regular Contributor
timestamp: June 29, 2015, 06:58:30 am
content: I got a packet of 8mm half watt warm white "straw hat" LEDs earlier this week, and threw together a couple little flicker-flame candles with some junk box parts. I used a combination of a slow linear-interpolated random intensity variation with a low-amplitude random flicker overlaid on it.The candle effect is rather nice, and I would say the effect is quite a bit more pleasant than the typical $0.50 Chinese LED tea candle.The circuit is extremely simple and should be pretty self-explanatory, pretty much just grabbed some parts and picked resistor values that sounded in the ballpark.An ATTiny45 generates a varying PWM signal using a PRNG and linear interpolation, which drives the gate of the mosfet (or transistor base) that drives the LED, and a diode sits up front to protect everything from when I inevitably stuff a battery in backwards.The LED threshold is around 2.8V and the LEDs are way under-driven anyway, so I wasn't worried about the diode drop. A tactile switch provides the user interface.According to my (cheap...) bench supply, it draws in the realm of 10-20mA at 3.5V, so it should burn quite a while on an 18650.The source code attached doesn't sleep the microcontroller when it's "soft off", that exercise is left to the reader. O0Two variants are present, the little one uses a 2N3904 and is strapped to a 16340 holder, and the larger one uses a TINY (2mm^2!) Panasonic FK3P02110 mosfet and is strapped to a 18650 holder. (Why? I had a few that I tossed into an order months ago on a lark, because TINY MOSFET!)The larger one has a diffuser meticulously crafted from a ping-pong ball and super glued on, and the smaller one I just scuffed up the LED with sand paper to get rid of the bright "caustic" projection from the curved edge of the LED.I soldered the lil' FET on a perfboard pad upside down, and then "bonded out" using 30ga wires and my tiniest, sharpest soldering iron tip. Wasn't terribly difficult, but does require a steady hand and desire to do something kind of pointlessly difficult.Source code is <100 lines of C, just copypasta into a new AVR Studio project (or whatever your favorite toolchain is...):http://pastebin.com/sj9n2RL5In action:http://gfycat.com/PossibleExaltedEel

author: Pjotr
author_rank: Frequent Contributor
timestamp: June 29, 2015, 11:06:03 am
content: Quote from: kmm on June 29, 2015, 06:58:30 amDo you know the Chinese candles often use the same music chip as used in music postcards?If you connect a small speaker across the led, don't be surprised you will hear something like "Happy birthday to you" or "When the saints go marching in" :lol:

author: kmm
author_rank: Regular Contributor
timestamp: June 29, 2015, 06:28:16 pm
content: Hah, I had no idea!Explains the repetitive and often "structured" appearance I've noticed in the cheapo ones.I figured they were just using a really short LFSR or lookup table. A music chip never even occurred to me, but it does make sense in a janky "we have a billion of these chips to get rid of" way.

author: richard.cs
author_rank: Super Contributor
timestamp: June 29, 2015, 09:45:29 pm
content: They had some in a restaurant I was in last week which were clearly mixing red and green, perhaps an rgb led. There was that effect where you move your head quickly and the colurs separate, similar to certain types of projectors that rotate through the colours - I find it really distracting.

author: kmm
author_rank: Regular Contributor
timestamp: June 30, 2015, 01:38:50 am
content: Packet of 5mm flat-top LEDs showed up today, also in warm white...This one uses a 2N7000 and hangs loose with no perfboard.Edit: Did a ghetto current measurement of the 18650 version with my scope and a 10 ohm resistor, and a less ghetto measurement with my meter."Off" state it draws around 4mA, "on" it (approximately) averages around 21mA, assuming a 3.7V supply.The square pulses are flashes generated when the state/mode changes. It steps through ON -> fastest -> [...] -> slowest -> OFF as the button is pressed, at least when it's not skipping steps due to switch bounce (or a bug, not entirely sure...).

author: kmm
author_rank: Regular Contributor
timestamp: July 01, 2015, 06:51:18 am
content: Now it just gets a bit silly.Omitted transistor on these since it occurred to me that this AVR can sink at least 10mA on its own, and they don't need to be driven hard to begin with.I'm using a 390 ohm resistor to limit the LED current to around 6mA, for a total current draw of around 7-10mA dependent on activity, with a 5V supply.May make a pile more (still have at least 3/4ths of a tube of Tiny45s) and dangle them from magnet wire to form a chandelier.A 500mA USB power brick should be more than adequate for powering the whole swarm.