# LED candles: simple, easy, cheap

## Overview

LED candles are very common these days.&nbsp; It's easy to see the attraction -- there's no fire danger and they never need to be replaced (just batteries).&nbsp; But there's such a wide variation in price and quality that it's hard to know what to purchase.&nbsp; Some store-bought candles flicker very realistically, others just seem to blink.&nbsp; Some use plain white LEDs, some look like real flames.&nbsp; And there's no way to know how good a candle will look without buying it.

Thankfully, with Adafruit's Gemma microcontroller and an RGB LED pixel, making your own LED candle only takes a couple of minutes.&nbsp; Because the LED can create any color and the Gemma can control the flickering very precisely, it will look better than any store-bought candle ever could.&nbsp; Because the parts are so cheap, it will cost much less too!

Info: 

Before you get started, follow the&nbsp;[Gemma M0 guide](../../../../adafruit-gemma-m0/circuitpython-digital-in-out?view=all)&nbsp;or the&nbsp;[Classic Introducing&nbsp;GEMMA guide](../../../../introducing-gemma/introduction)&nbsp;

# LED candles: simple, easy, cheap

## Parts

Each candle needs:

- one&nbsp;[Gemma M0](https://www.adafruit.com/product/3501)&nbsp;or&nbsp;[GEMMA v2 wearable microcontroller](http://www.adafruit.com/products/1222 "Link: http://www.adafruit.com/products/1222")
- one through-hole diffused [NeoPixel 5mm](https://www.adafruit.com/product/1938) or [NeoPixel 8mm](https://www.adafruit.com/product/1734)
- a power source - either a [battery pack](https://www.adafruit.com/product/783) or a USB cable.

You'll also need a soldering iron and a computer.

![](https://cdn-learn.adafruit.com/assets/assets/000/047/738/medium800/led_pixels_p1.jpg?1509306848)

# LED candles: simple, easy, cheap

## Build It!

![](https://cdn-learn.adafruit.com/assets/assets/000/047/740/medium800/led_pixels_LED_Candles-fritzing.png?1509307247)

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/047/743/medium800/led_pixels_p2.jpg?1509307335)

Info: 

To assemble the candle, bend the pins so they reach the correct connectors on the Gemma.

- LED data-in to Gemma D0
- LED 5V to Gemma Vout
LED Ground to Gemma GND

The LED's data-out pin is not needed and located closest to the flat side of the LED.&nbsp; You can cut it off or just bend it out of the way.

Put a drop of solder on each connection to hold it.

# LED candles: simple, easy, cheap

## Arduino Code

Info: 

Installing Arduino libraries is a frequent stumbling block. If this is your first time, or simply needing a refresher, please read the&nbsp;[All About Arduino Libraries](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use)&nbsp;tutorial.[![](/assets/divider_icon-45a76f14a0234c47f43488c60c9d77a1701a0ff9f3a09498809a26305ce3df23.gif)](../../../../neopixel-punk-collar/3634)If the library is correctly installed (and the Arduino IDE is restarted), you should be able to navigate through the “File” rollover menus as follows:  
  
**File→Sketchbook→Libraries→Adafruit\_NeoPixel→strandtest**

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/LED_Candles/LED_Candles.ino

From the&nbsp; **Tools→Board** &nbsp;menu, select&nbsp;the&nbsp;device you are using: **&nbsp;**

- **Adafruit Gemma M0**
- **Adafruit Gemma 8 MHz** &nbsp;

Connect the USB cable between the computer and your device. The original Gemma (8 MHz) need the reset button pressed on the board, then click the upload button (right arrow icon) in the Arduino IDE. You do not need to press the reset on the newer Gemma M0.

When the battery is connected, you should get a light show from the LEDs. All your pixels working? Great! You can take apart this prototype and get ready to put the pixels in the collar. Refer to the&nbsp;[NeoPixel Uberguide](../../../../adafruit-neopixel-uberguide)&nbsp;for more info.

&nbsp;

# LED candles: simple, easy, cheap

## CircuitPython Code

![](https://cdn-learn.adafruit.com/assets/assets/000/047/744/medium800/led_pixels_gemma-cp.jpg?1509312458)

 **GEMMA&nbsp;M0** &nbsp;boards can&nbsp;run&nbsp; **CircuitPython** &nbsp;— a different approach to programming compared to Arduino sketches. In fact,&nbsp; **CircuitPython comes&nbsp;factory pre-loaded on GEMMA&nbsp;M0**. If you’ve overwritten it with an Arduino sketch, or just want to learn the basics of setting up and using CircuitPython, this is explained in the&nbsp;[**Adafruit GEMMA&nbsp;M0 guide**](../../../../adafruit-gemma-m0/circuitpython-setup-1).

Info: 

Below is CircuitPython code that works&nbsp;similarly (though not exactly the same) as the Arduino sketch shown on a prior page. To use this, plug the GEMMA M0 into USB…it should show up on your computer as a small&nbsp; **flash drive** …then edit the file “ **main.py** ” with your text editor of choice. Select and copy the code below and paste it into that file,&nbsp; **entirely replacing its contents** &nbsp;(don’t mix it in with lingering bits of old code). When you save the file, the code should&nbsp; **start running almost immediately** &nbsp;(if not, see notes at the bottom of this page).

**If GEMMA M0 doesn’t show up as a&nbsp;drive, follow the GEMMA M0 guide link above to prepare the board for CircuitPython.**

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/LED_Candles/code.py

This code requires the&nbsp; **neopixel.py** &nbsp;library. A factory-fresh board will have this already installed. If you’ve just reloaded the board with CircuitPython, create the “lib” directory and then&nbsp;[download neopixel.py from Github](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel).

[Download neopixel.py from GitHub](https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel)
# LED candles: simple, easy, cheap

## Light it up!

![](https://cdn-learn.adafruit.com/assets/assets/000/047/754/medium800/led_pixels_l1.jpg?1509312831)

# Power
To power the candle, you can either use a USB cable or a battery pack.&nbsp; Two CR2032 batteries are enough to light it up, thanks to the Gemma's voltage regulator dropping the power to 3V.&nbsp; I haven't done any testing to see how long they'll last; you'll know the batteries are getting low when you start seeing green flickering as the candle dims.

Since I've built several of these and I want them side-by-side, I found a cheap powered USB hub that works very nicely.

![](https://cdn-learn.adafruit.com/assets/assets/000/047/753/medium800/led_pixels_l2.jpg?1509312806)

# Diffuser
To make the candle look real, it will need to be covered by a semi-opaque chimney or globe to diffuse the LED's light.&nbsp; I found some frosted glass chimneys at my local hardware store.&nbsp; They're supposed to be replacements for broken fixtures, but they look great here.&nbsp; Almost anything is possible -- consider a structure covered in tissue paper or a white paper bag or even an old wax candle that's been hollowed out.

![](https://cdn-learn.adafruit.com/assets/assets/000/047/755/medium800/led_pixels_l3.jpg?1509312970)

# Final thoughts
In this project, I used one Gemma for each candle, which makes it very easy to run them from batteries and place them anywhere.&nbsp; But there's no reason why one Gemma couldn't run multiple LEDs if they were wired together.&nbsp; This could be done to create a string of candles or even a multi-wick LED candle.

This LED candle only flickers a realistic yellow/orange color, but there's no reason it couldn't have different a colored "flame", or even randomly rotate through colors.

**One small caveat:** &nbsp;because of the way NeoPixels are designed, their three internal LEDs (red, green and blue) constantly flicker at 400 Hz to hold a color.&nbsp; This is far too fast to be seen with the human eye, so they appear to have a steady, smooth light.&nbsp; But cameras can see the refresh flicker.&nbsp; In still photos, the effect creates "banding" in the photo (visible in the photos above).&nbsp; In videos, the effect creates constantly moving horizontal bands that are very noticable.&nbsp; DotStar LEDs don't have this problem; hopefully Adafruit will come out with through-hole versions of those soon!

&nbsp;


## Featured Products

### Adafruit GEMMA M0 - Miniature wearable electronic platform

[Adafruit GEMMA M0 - Miniature wearable electronic platform](https://www.adafruit.com/product/3501)
The **Adafruit Gemma M0** is a super small microcontroller board, with just enough built-in to create many simple projects. It may look small and cute: round, about the size of a quarter, with friendly alligator-clip sew pads. But do not be fooled! The Gemma M0 is incredibly...

In Stock
[Buy Now](https://www.adafruit.com/product/3501)
[Related Guides to the Product](https://learn.adafruit.com/products/3501/guides)
### Adafruit GEMMA v2 - Miniature wearable electronic platform

[Adafruit GEMMA v2 - Miniature wearable electronic platform](https://www.adafruit.com/product/1222)
 **Deprecation Warning: The Gemma bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Gemma so that people can maintain some older projects, we no longer recommend it.** <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1222)
[Related Guides to the Product](https://learn.adafruit.com/products/1222/guides)
### Arduino GEMMA - Miniature wearable electronic platform

[Arduino GEMMA - Miniature wearable electronic platform](https://www.adafruit.com/product/2470)
What do you get when you combine&nbsp;an Adafruit classic with geniuses at Arduino? The Arduino GEMMA!&nbsp;It's a tiny wearable platform board with a lot of might in a 1" diameter package. Powered by a Attiny85 and programmable with an Arduino IDE over USB, you'll be able to...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2470)
[Related Guides to the Product](https://learn.adafruit.com/products/2470/guides)
### NeoPixel Diffused 8mm Through-Hole LED - 5 Pack

[NeoPixel Diffused 8mm Through-Hole LED - 5 Pack](https://www.adafruit.com/product/1734)
LOLwut? NeoPixels in through-hole variety? Oh yes, we haz them! If you like NeoPixel strips you'll luv these 8mm diffused through-hole NeoPixels. All the single-pin-controlling-hundreds-of-LEDs goodness in a breadboard friendly format. Each LED looks just like your classic through-hole 8mm...

In Stock
[Buy Now](https://www.adafruit.com/product/1734)
[Related Guides to the Product](https://learn.adafruit.com/products/1734/guides)
### NeoPixel Diffused 5mm Through-Hole LED - 5 Pack

[NeoPixel Diffused 5mm Through-Hole LED - 5 Pack](https://www.adafruit.com/product/1938)
LOLwut? NeoPixels in 5mm through-hole variety? Oh yes, we haz them! If you like NeoPixel strips you'll luv these 5mm **diffused** through-hole NeoPixels. All the single-pin-controlling-hundreds-of-LEDs goodness in a breadboard friendly format. Each LED looks just like a...

In Stock
[Buy Now](https://www.adafruit.com/product/1938)
[Related Guides to the Product](https://learn.adafruit.com/products/1938/guides)
### 2 x CR2032 Coin Cell Battery Holder - 6V output - On/Off switch

[2 x CR2032 Coin Cell Battery Holder - 6V output - On/Off switch](https://www.adafruit.com/product/783)
This tiny coin cell battery holder is ideal for small portable or wearable projects. It holds two 20mm coin cells (2032 or CR2032 are the most popular size) in series to generate 6V nominal. (If you want only 3V, we suggest sticking a crumpled piece of tin foil in one of the slots.) 20mm coin...

In Stock
[Buy Now](https://www.adafruit.com/product/783)
[Related Guides to the Product](https://learn.adafruit.com/products/783/guides)
### CR2032 Lithium Coin Cell Battery

[CR2032 Lithium Coin Cell Battery](https://www.adafruit.com/product/654)
A perfect match for our [sew-able coin cell holder](http://www.adafruit.com/products/653). This non-rechargeable coin cell is CR2032 sized: 20mm diameter, 3.2mm thick. It has a nominal voltage output of 3V (although it starts a little high at 3.2V and slowly drifts down to 2.5V as...

In Stock
[Buy Now](https://www.adafruit.com/product/654)
[Related Guides to the Product](https://learn.adafruit.com/products/654/guides)
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)

## Related Guides

- [Porting an Arduino library to CircuitPython: VL6180X Distance Sensor](https://learn.adafruit.com/porting-an-arduino-library-to-circuitpython-vl6180x-distance-sensor.md)
- [NeoPixel Tiara](https://learn.adafruit.com/neopixel-tiara.md)
- [NeoPixel Flame Torch](https://learn.adafruit.com/neopixel-flame-torch.md)
- [Animated NeoPixel Glow Fur Scarf](https://learn.adafruit.com/animated-neopixel-gemma-glow-fur-scarf.md)
- [CircuitPython Hardware: PCA9685 PWM & Servo Driver](https://learn.adafruit.com/micropython-hardware-pca9685-pwm-and-servo-driver.md)
- [Trinket Ultrasonic Rangefinder](https://learn.adafruit.com/trinket-ultrasonic-rangefinder.md)
- [Rainbow Chakra LED Hoodie](https://learn.adafruit.com/rainbow-chakra-led-hoodie.md)
- [How to Choose a Microcontroller](https://learn.adafruit.com/how-to-choose-a-microcontroller.md)
- [NeoPixel Punk Collar](https://learn.adafruit.com/neopixel-punk-collar.md)
- [Let’s Put LEDs in Things!](https://learn.adafruit.com/lets-put-leds-in-things.md)
- [Bandolier of Light](https://learn.adafruit.com/bandolier-of-light.md)
- [CircuitPython Hardware: LED Backpacks & FeatherWings](https://learn.adafruit.com/micropython-hardware-led-backpacks-and-featherwings.md)
- [3D Printed LED Fire Horns](https://learn.adafruit.com/3d-printed-led-fire-horns.md)
- [3D Printed Unicorn Horn](https://learn.adafruit.com/3d-printed-unicorn-horn.md)
- [Jewel Hair Stick](https://learn.adafruit.com/jewel-hair-stick.md)
