Lab set Program-5
Develop a program to deploy smart street light system using LDR sensor.
Objective
To develop a smart street light system using Arduino and an LDR (Light Dependent Resistor) that automatically turns ON the streetlight (LED) in darkness and turns it OFF in daylight.
Learning Outcomes
By the end of this experiment, students will be able to:
-
Understand the working of an LDR sensor.
-
Interface an analog sensor (LDR) with Arduino.
-
Write Arduino code to make decisions based on sensor values.
-
Simulate the circuit in Tinkercad.
Components (from Tinkercad Palette)
-
Arduino Uno board
-
Breadboard
-
LDR (Light Dependent Resistor)-Search for Photoresistor
-
10kΩ Resistor (for voltage divider)
-
LED (to represent street light)
-
220Ω Resistor (for LED)
-
Jumper wires
Circuit Wiring (Exact Steps in Tinkercad)
-
Place the LDR and connect:
-
One leg of LDR → 5V.
-
Other leg of LDR → A0 (Analog pin).
-
From the same leg → connect a 10kΩ resistor to GND (this makes a voltage divider).
-
-
Place the LED:
-
LED Anode (long leg) → connect to digital pin 9 via 220Ω resistor.
-
LED Cathode (short leg) → GND.
-
-
Ensure Arduino Uno is powered through Tinkercad simulation.
Arduino Sketch
// Smart Street Light System using LDR
int ldrPin = A0; // LDR connected to analog pin A0
int ledPin = 9; // LED connected to digital pin 9
int ldrValue = 0; // Variable to store LDR value
int threshold = 500; // Threshold value for darkness
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
ldrValue = analogRead(ldrPin); // Read LDR value
Serial.println(ldrValue); // Print value to Serial Monitor
if (ldrValue < threshold) { // If it's dark
digitalWrite(ledPin, HIGH); // Turn ON LED (street light)
} else {
digitalWrite(ledPin, LOW); // Turn OFF LED
}
delay(500); // small delay for stability
}
How It Works
-
The LDR changes resistance based on light.
-
In daylight, resistance is low → higher analog reading → LED stays OFF.
-
In darkness, resistance is high → lower analog reading → LED turns ON.
Simulating Day & Night
-
In Tinkercad, select the Photoresistor.
-
In the Inspector panel (right side), adjust the Light Level slider.
-
Move it towards bright → Arduino reads high values → LED turns OFF.
-
Move it towards dark → Arduino reads low values → LED turns ON.
-
This mimics day and night conditions.
-
-
The threshold (500) decides when to switch ON/OFF.
Common Mistakes & Quick Fixes
-
LED not glowing? Check resistor orientation (220Ω should be in series).
-
Wrong sensor values? Ensure the LDR and 10kΩ resistor are correctly connected in a voltage divider.
-
LED always ON/OFF? Adjust threshold (between 300–700 based on Tinkercad simulation).
Viva / Check-Your-Understanding
-
Why do we use a voltage divider with an LDR?
-
How does an LDR’s resistance change with light intensity?
-
What happens if you remove the 10kΩ resistor?
-
Can this circuit be extended to multiple streetlights?
Extensions (Mini-Tasks)
-
Replace the single LED with 4 LEDs to represent a road.
-
Control brightness of LED using
analogWrite()(PWM). -
Add a Buzzer that beeps when it gets too dark.
Lab Record (Suggested Headings)
-
Title
-
Objective
-
Components Required
-
Circuit Diagram (from Tinkercad)
-
Arduino Code
-
Output

Comments
Post a Comment