All programs
IoT - Lab Manual (Simplified) · BCS7O3 IoT (Arduino · C++)

Problem Statement Program 1

Develop a program to blink 5 LEDs back and forth.

Components Required Hardware

Arduino Uno Board – 1
Breadboard – 1
LED – 5
220Ω Resistor – 5
Jumper Wires – As Required
USB Cable – 1
Arduino IDE Software

Procedure Step by step

Step 1:

Take an Arduino Uno board, breadboard, five LEDs, five 220Ω resistors, jumper wires, and a USB cable.

Step 2:

Insert the five LEDs into the breadboard.

Step 3:

Connect the anode (long leg) of LED1 to Arduino Digital Pin 5.

Step 4:

Connect the anode (long leg) of LED2 to Arduino Digital Pin 6.

Step 5:

Connect the anode (long leg) of LED3 to Arduino Digital Pin 7.

Step 6:

Connect the anode (long leg) of LED4 to Arduino Digital Pin 8.

Step 7:

Connect the anode (long leg) of LED5 to Arduino Digital Pin 9.

Step 8:

Connect the cathode (short leg) of each LED to one end of a 220Ω resistor.

Step 9:

Connect the other end of each resistor to the GND (Ground) rail of the breadboard.

Step 10:

Connect the Arduino 5V pin to the positive power rail of the breadboard.

Step 11:

Connect the Arduino GND pin to the negative power rail of the breadboard.

Step 12:

Connect the Arduino board to the computer using a USB cable.

Step 13:

Open the Arduino IDE.

Step 14:

Select Tools → Board → Arduino Uno.

Step 15:

Select the correct COM Port.

Step 16:

Copy and paste the Arduino program into the Arduino IDE.

Step 17:

Click on the Upload button.

Step 18:

Wait until the upload is completed successfully.

Step 19:

Observe the LEDs blinking one after another in the forward direction and then in the reverse direction continuously.

Circuit Connection Wiring

Digital Pin 5 → LED1 Anode
Digital Pin 6 → LED2 Anode
Digital Pin 7 → LED3 Anode
Digital Pin 8 → LED4 Anode
Digital Pin 9 → LED5 Anode
All LED Cathodes → Through 220Ω Resistor → GND
Arduino 5V → Breadboard Positive Rail
Arduino GND → Breadboard Negative Rail

Circuit Diagram 1 image

Download the clean, watermark-free circuit diagram — ₹1.00

Arduino Code (C++) Source

program1.cpp
int LED1 = 5;
int LED2 = 6;
int LED3 = 7;
int LED4 = 8;
int LED5 = 9;

int del = 100;

void setup()
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(LED5, OUTPUT);
}

void loop()
{
  digitalWrite(LED1, HIGH);
  delay(del);
  digitalWrite(LED1, LOW);

  digitalWrite(LED2, HIGH);
  delay(del);
  digitalWrite(LED2, LOW);

  digitalWrite(LED3, HIGH);
  delay(del);
  digitalWrite(LED3, LOW);

  digitalWrite(LED4, HIGH);
  delay(del);
  digitalWrite(LED4, LOW);

  digitalWrite(LED5, HIGH);
  delay(del);
  digitalWrite(LED5, LOW);

  digitalWrite(LED4, HIGH);
  delay(del);
  digitalWrite(LED4, LOW);

  digitalWrite(LED3, HIGH);
  delay(del);
  digitalWrite(LED3, LOW);

  digitalWrite(LED2, HIGH);
  delay(del);
  digitalWrite(LED2, LOW);
}

Viva Q&A Interview prep · PDF

Read the full Viva Q&A for this program in a protected viewer, then download the PDF whenever you like.

Protected content · © VTU Developer · Unauthorised distribution is prohibited