Experiment 1 - LED Blinking
Experiment 1 - LED Blinking
Experiment 1 - LED Blinking
Components required:
Software Hardware
Arduino UNO Board
Tinkercad Arduino UNO Cable
Arduino IDE (To be installed in Laptop) LED’s (Red-1, Green-1, White-1)
Resistors – 3 (1KΩ each)
Jumper wires
Description:
LED blinking is the most beginner & easy step to start experiments with arduino. Firstly, identify
anode (+ve) & cathode (-ve) leg of LED. Following diagram gives a clear idea of LED.
Now connect a resistor to positive leg and other end of resistor to 5V.Cathode will be connected
to Arduino GPIO, in this case pin 13. Final circuit will look as below.
Pre-Requisites:
Electronics fundamentals
Basic knowledge about Arduino Pins
Pre-Lab:
1. What are the components required for blinking LED using Arduino?
1 × Breadboard.
1 × Arduino Uno R3.
1 × LED.
1 × 330Ω Resistor.
2 × Jumper.
2. What is the use of Arduino program with LED blink?
Arduino program in LED blink is useful to see the physical output of the experiment. It
blinks the on-board LED and turns it on and off according to the delay given in the
code/program.
3. List out the types of LED’s.
Dual In-Line Package (DIP) LEDs. DIP LED Lights. DIP LED chips are the
original LED chips
Surface Mounted Diode (SMD) LEDs.
Chip on Board (COB) LEDs.
4. How many analog pins are present in the Arduino Boards?
The Arduino UNO has 6 analog inputs, labeled A0 through A5, each of which provide 10
bits of resolution.
5. List the important uses of LEDs.
LEDs are commonly used in,
Streetlights
Parking garage lighting
Refrigerated case lighting.
Walkway and other outdoor area lighting
In-Lab:
Programs:
A. Blink an LED with delay of 2 seconds
#define LED 13
void setup()
{
//put your code inside this setup()to execute one time
pinMode(LED, OUTPUT); // making 13 pin as output
}
void loop()
{
//put your code inside this loop()to execute infinite no of times
digitalWrite(LED, HIGH); //turning on the LED
delay(2000); // Wait for 2000 millisecond(s)
digitalWrite(LED, LOW); //turning on the LED
delay(2000); // Wait for 2000 millisecond(s)
}
B. Blink 2 LED’s alternatively with a delay of one second
#define RED_LED 13
#define GREEN_LED 12
void setup()
{
//put your code inside this setup()to execute one time
pinMode(RED_LED, OUTPUT); // making 13 pin as output
pinMode(GREEN_LED, OUTPUT); // making 12 pin as output
}
void loop()
{
//put your code inside this loop()to execute infinite no of times
digitalWrite(RED_LED, HIGH); //turning on RED LED
digitalWrite(GREEN_LED, LOW); //turning off GREEN LED
delay(1000); // Wait for 1000 millisecond(s)
Procedure:
1. Give the connections to the Arduino board as shown in the connection diagram.
2. Open Arduino IDE in the computer
3. Create new file File_--→ New
4. Type your program and Save it in appropriate location in your computer.
5. Compile your program by clicking Verify option in the menu.
6. Once the program compiled successfully, connect the Arduino board to the computer
using USB cable.
7. After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno option.
8. After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM port 3
(name may appear differently for other computers).
9. Note that this port option will be displayed only when board is connected to
computer.
10. Now upload the program to the Arduino board by clicking Upload option.
11. Observe the output.
Connection Diagram:
Post-Lab:
1. To Blink an LED with a random delay.
Program:
int n1=5;
void setup()
{
Serial.begin(9600);
pinMode(8,OUTPUT);
}
void loop()
{
int dtime=random(n1);
int dtime1=dtime*1000;
Serial.println(dtime);
Serial.println(dtime1);
digitalWrite(8,HIGH);
delay(dtime1);
digitalWrite(8,LOW);
delay(dtime1);
Program:
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
}