Electronic or flameless candles are an alternative to traditional wick candles. These are used for home décor and do not carry the risk of fire as these have LEDs that glow instead of an open flame.
This project shows how to make a simple electronic candle using Arduino Uno board and three LEDs. You can increase the number of LEDs as per requirement. The author’s prototype is shown in Fig. 1.
Circuit and working
The circuit diagram of the electronic candle is shown in Fig. 2. It is built around Arduino Uno board (BOARD1), three LEDs (LED1 through LED3) and three resistors (R1 through R3).
The technology used for this electronic candle is based on pulse width modulation (PWM). An LED is a diode that works only in forward direction. If you reduce the voltage, it can be easily dimmed either through PWM or by lowering the forward current. In simple terms, an LED receives a DC cycle of different duty cycles (on period), as shown in Fig. 3.
Arduino IDE is used to compile and upload the source code (candle.ino) to the board. Select the correct board and COM port from BoardTools menu in Arduino IDE and upload the program through the standard USB port in the computer.
In source code void setup(), pin mode is defined; that is, 9, 10 and 11 pins are defined as output pins. In void loop(), analogWrite (pinNumber, Intensity) function is used for PWM. Intensity can be varied from 0 to 255 from the source code. The “random(vary)+fix” function is used to get a random value from 0 to 195 and then add 60 to make 255.
You can also vary the random number in the code like random(160)+90 according to convenience.
Construction and Testing
Assemble the components as shown in Fig. 2. Take three LEDs, one red and two yellow (you can also take blue instead of yellow), to get an illusion of a candle. Connect it with Arduino Uno using an external jumper wire. This is done because Arduino Uno will get power supply via USB. Cover the LEDs with an opaque box by keeping the top side slightly open for light to come out to make it look like a real candle.
Download Source Folder
Mahendra Raisinghani and Sagar Raj Gupta are co-founders of Shoolin Labs, Jaipur