Fork me on GitHub

Project Notes

#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:

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.





The CandleEmulator.ino code is a refactored version of CandeflickerLED.c:

  • simplified and cleaned up the algorithm
  • now Arduino-specific

Credits and References

Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.