#616 Candle Emulator
An Arduino LED candle emulation.
Here’s a quick demo..
LEDs and candle lights that appear to flicker like real candles have become quite mainstream. There are many imitation candle products available, and some even with wireless control.
This all seems to have been enabled by low-cost microcontrollers with a smart flicker emulator embedded into LED package itself:
Why a microcontroller? Well it turns out that emulating a candle flicker is not so straight-forward. I just discovered a wonderful series of articles by “Tim” concerning LED candles:
- reverse engineering a real candle
- reverse engineering an LED candle
- making a LED-Candle based on the 3 cent MCU
In this little project I am simply exploring the emulator code that Tim released and adapting it for Arduino.
Emultion Algorithm Essentials
Tim’s work basically established that flicker LEDs:
- drive the LED with a PWM signal at around 440Hz
- use 16 levels of brightness
- the lowest 4 hardly ever used (<0.4% of samples)
- 50% of samples are max brightness
- the other 12 levels are almost evenly distributed
- changes the brightness level every 32 cycles (Tim calls a “frame”)
Randomly selected pin 11 on the Arduino for the LED. The code implements a pulse-width modulation (PWM) algorithm but just uses a GPIO pin to drive the LED (so does not need a pin with hardware PWM).
A low value (220Ω) current-limiting resistor ensures decent brightness with a yellow LED while keeping current within spec.
- simplified and cleaned up the algorithm
- now Arduino-specific