Home > Other >Special Application Circuits > Make a simple electronic candle using Arduino Uno and LEDs

Make a simple electronic candle using Arduino Uno and LEDs

Source: InternetPublisher:D先生 Keywords: led development board Arduino Updated: 2024/03/26

For beginners in microcontroller development, how to use the Arduino Uno development board to make an electronic candle? Electronic or flameless candles are an alternative to traditional wick candles and are a ubiquitous thing in life. These lamps are mostly used for home decoration, so you don’t have to worry about catching fire because they don’t emit open flames, but LEDs.

In this article, engineers show how to make a simple electronic candle using an Arduino Uno board and three LEDs. You can increase the number of LEDs as needed.

Circuit and working principle

The circuit diagram of the electronic candle is shown in the figure below. It is built around an Arduino Uno board (BOARD1), three LEDs (LED1 to LED3) and three resistors (R1 to R3).

Electronic candle circuit diagram

The technology used in this electronic candle is based on Pulse Width Modulation (PWM). LEDs are diodes that only operate in the forward direction. If you reduce the voltage, you can easily dim it by PWM or reducing the forward current. Simply put, the LED receives DC cycles with different duty cycles (on-cycles) as shown in the image below.

Easily dim it via PWM or reducing forward current

Arduino IDE is used to compile the source code (candle.ino) and upload it to the development board. Select the correct Board and COM port from the Arduino IDE's Board Tools menu and upload the program via a standard USB port in your computer.

In the source code void setup(), the pin mode is defined. That is, pins 9, 10 and 11 are defined as output pins. In void loop(), analogWrite(pinNumber,Intensity) function is used for PWM. Strength can vary from 0 to 255 in the source code. "

"random(vary)+fix" function is used to get a random value between 0 and 195 and then add 60 to 255. Additionally, you can also change the random number in the code as needed, such as random(160)+90.

How to build a circuit?

Take three LEDs, one red and two yellow (can be blue or other colors) to create the illusion of candles. Use external jumper wires to connect it with the Arduino Uno. This is done because the Arduino Uno will be powered via USB. Cover the LED with an opaque box, making it look like a real candle by leaving the top slightly open to let the light out.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号