Sunteți pe pagina 1din 3

CS 11/Group_4_Borromeo,Galanida,Pabilan,Paypa,Tejero

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.

6. Open up the Arduino IDE.


7. Program the Arduino UNO.
8. Encode or copy then edit the code for this section.
9. Plug the Arduino UNO board into the laptop with a USB cable.
10. Upload onto board.
Make sure the serial port is set. In this case, COM4 and the correct board is selected, that is
Arduino UNO is selected from the dropdown menu at the top left corner of the Arduino
application. Then upload the code unto the board by clicking upload at the top left corner.
11. Monitor the Arduino board and the circuit. The LEDs should be flickering like a candle flame.

RESULTS AND DISCUSSIONS


Here is the code that we encode in the sketch:
int ledPin1 = 10;
int ledPin2 = 9;
int ledPin3 = 11;

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

S-ar putea să vă placă și