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

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

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics 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.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader