Fork me on GitHub

Project Notes

#616 Candle Emulator

An Arduino LED candle emulation.

Build

Here’s a quick demo..

clip

Notes

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:

flicker-chip

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”)

Construction

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.

bb

schematic

bb_build

Code

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

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

Credits and References

About LEAP#616 LEDArduino
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, 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 (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.