Exp. No - 1
Exp. No - 1
Exp. No - 1
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.
Connection Diagram:
Circuit/Schematic Diagram:
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:
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.
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)
}
Post-Lab:
1. To Blink an LED with a random delay.
Program:
int ledPin=8; //definition digital 8 pins as pin to control the LED
void setup()
{
pinMode(ledPin,OUTPUT); //Set the digital 8 port mode, OUTPUT: Output mode
}
void loop()
{
digitalWrite(ledPin,HIGH); //HIGH is set to about 5V PIN8
delay(3000); //Set the delay time, 1000 = 1S
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);
}
Results: