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

Problem Statement Program 5

Develop a program to deploy Smart Street Light System using LDR Sensor.

To develop a Smart Street Light System using an Arduino Uno and an LDR sensor. The system automatically turns the street light (LED) ON during darkness and OFF during daylight. This experiment helps in understanding light sensing, analog input, and automatic lighting control using Arduino.

Components Required Hardware

Arduino Uno Board – 1
LDR (Light Dependent Resistor) – 1
10kΩ Resistor – 1
LED – 1
220Ω Resistor – 1
Breadboard – 1
Jumper Wires – As Required
USB Cable – 1
Arduino IDE Software

Procedure Step by step

Step 1:

Take an Arduino Uno board, LDR sensor, LED, 10kΩ resistor, 220Ω resistor, breadboard, jumper wires, and USB cable.

Step 2:

Place the LDR and the 10kΩ resistor on the breadboard to form a voltage divider circuit.

Step 3:

Connect one terminal of the LDR to the Arduino 5V pin.

Step 4:

Connect the other terminal of the LDR to Analog Pin A0 of the Arduino.

Step 5:

Connect the same terminal of the LDR to one terminal of the 10kΩ resistor.

Step 6:

Connect the other terminal of the 10kΩ resistor to the Arduino GND pin.

Step 7:

Insert the LED on the breadboard.

Step 8:

Connect the anode (long leg) of the LED to Digital Pin 10 through a 220Ω resistor.

Step 9:

Connect the cathode (short leg) of the LED to Arduino GND.

Step 10:

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

Step 11:

Open the Arduino IDE.

Step 12:

Select Tools → Board → Arduino Uno.

Step 13:

Select the correct COM Port.

Step 14:

Copy and paste the Arduino program.

Step 15:

Compile and upload the program.

Step 16:

Open the Serial Monitor and set the baud rate to 9600.

Step 17:

Cover the LDR sensor to simulate darkness. The LED turns ON.

Step 18:

Expose the LDR sensor to light. The LED turns OFF.

Circuit Connection Wiring

LDR Terminal 1 → Arduino 5V
LDR Terminal 2 → Arduino Analog Pin A0
LDR Terminal 2 → 10kΩ Resistor
10kΩ Resistor → Arduino GND
LED Anode (+) → 220Ω Resistor → Arduino Digital Pin 10
LED Cathode (-) → Arduino GND
Arduino USB → Computer

Circuit Diagram 1 image

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

Arduino Code (C++) Source

program5.cpp
// Smart Street Light System using LDR

int led = 10;
int ldr = A0;

void setup()
{
  Serial.begin(9600);

  pinMode(led, OUTPUT);
  pinMode(ldr, INPUT);
}

void loop()
{
  int ldrStatus = analogRead(ldr);

  Serial.print("LDR Value: ");
  Serial.println(ldrStatus);

  if (ldrStatus <= 300)
  {
    digitalWrite(led, HIGH);
    Serial.println("Street Light: ON (Dark detected)");
  }
  else
  {
    digitalWrite(led, LOW);
    Serial.println("Street Light: OFF (Sufficient light)");
  }

  delay(500);
}
Protected content · © VTU Developer · Unauthorised distribution is prohibited