Documente Academic
Documente Profesional
Documente Cultură
Lab 3
ARDUINO LED CANDLE LIGHT
INTRODUCTION
A candle is an ignitable wick embedded in wax or another flammable solid substance such as
tallow that provides light.
However, in this activity we will use 3 LEDs and an Arduino to create a realistic fire effect that
could be used in a diorama, model railway and could be put one inside a frosted glass jar or tube and no-
one would know it wasn’t a real candle. It uses Pulse Width Modulation (PWM) to send random voltage
for a random period of time to an LED.
This randomness makes the LED seem to flicker like a candle light.
OBJECTIVES
1. To create and simulate a candle light effect using LEDs, Arduino UNO and some code trickery.
2. To know how to use PWM Pins to send randomly selected voltages to LEDs.
3. To familiarize the codes for flickering LED.
MATERIALS
• Arduino UNO with USB cable
• 3 LEDs (2 orange, 1 yellow)
• 6 Resistors (220 ohms)
• 4 jumper wires
• Breadboard
• Laptop
• Sticky notes
PROCEDURES
1. Insert the three LED to the breadboard.
2. Connect the 220-ohm resistors below the cathode pins of the 3 LEDs.
The breadboard has signs for positive (power) and negative (ground) connections. Place the
resistors on the breadboard, with one leg on the negative column (gnd) of the breadboard and
the other leg in a different hole located somewhere else on the breadboard as shown in the
diagram below.
CS 11/Group_4_Borromeo,Galanida,Pabilan,Paypa,Tejero
3. Connect the 3 jumper wires (white,orange) to the anode pins of the LEDs. (Note: We used
resistors to limit the current through LED.)
4. Plug in the 3 jumper wires to the Arduino UNO board in PWM pins number 9,10 and 11.
5. Connect a black jumper wire from GND to the negative rail on the breadboard.
void setup() {
pinMode(ledPin1,0);
pinMode(ledPin2,0);
pinMode(ledPin3,0);
}
void loop() {
analogWrite(ledPin1, random(100)+135);
analogWrite(ledPin2, random(100)+135);
analogWrite(ledPin3, random(100)+135);
delay(random(50));
}
CS 11/Group_4_Borromeo,Galanida,Pabilan,Paypa,Tejero
DOCUMENTATION