0% found this document useful (0 votes)
66 views4 pages

Practical 8

The document outlines a project for students to design and simulate an automatic light control system using an LDR and Arduino. It includes step-by-step instructions for setting up the simulation, wiring components, programming the Arduino, and testing the system. The exercise emphasizes real-time control, automation, and potential real-world applications, while also suggesting extensions for further development.

Uploaded by

clinton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views4 pages

Practical 8

The document outlines a project for students to design and simulate an automatic light control system using an LDR and Arduino. It includes step-by-step instructions for setting up the simulation, wiring components, programming the Arduino, and testing the system. The exercise emphasizes real-time control, automation, and potential real-world applications, while also suggesting extensions for further development.

Uploaded by

clinton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Simulating an Automatic Light Control System

Objective:
Students will design and simulate an automatic light control system using a light-dependent resistor
(LDR) that turns a light on when it gets dark and off when it gets light. This exercise reinforces concepts
of sensor-based input, real-time control, and automation.

Requirements:

 Laptop with internet access

 Free account on Tinkercad or Wokwi

 Basic knowledge of Arduino programming

 Basic understanding of light sensors (LDR) and actuators (LED)

Step-by-Step Instructions:

1. Setup the Simulation Environment (5 minutes):

 Log in to Tinkercad or Wokwi.

 Create a new Arduino project.

2. Design the Automatic Light Control System (10 minutes):

 Drag and drop the following components into the simulation workspace:

o Arduino Uno

o Light Dependent Resistor (LDR)

o LED (to simulate the light)

o Resistor (for LDR)

 Wire the components:

o Connect the LDR to an analog pin (e.g., A0) and to the 5V pin through a resistor.

o Connect the LED to a digital pin (e.g., pin 9) and to ground through a current-limiting
resistor.

o Ensure all components share a common ground.

3. Program the Arduino (20 minutes):

 Open the code editor in the simulator and use the following code for the light control system:

cpp

CopyEdit

int ldrPin = A0; // Pin connected to the LDR


int ledPin = 9; // Pin connected to the LED (simulating the light)

int ldrValue = 0; // Variable to store LDR sensor value

int threshold = 500; // Threshold value for turning the light on/off (adjustable)

void setup() {

pinMode(ledPin, OUTPUT); // Set the LED pin as output

Serial.begin(9600); // Start serial communication for debugging

void loop() {

// Read the value from the LDR sensor

ldrValue = analogRead(ldrPin);

// Print the LDR value to the serial monitor for debugging

Serial.print("LDR Value: ");

Serial.println(ldrValue);

// Control the light based on the LDR value

if (ldrValue < threshold) { // If it is dark (LDR value is low)

digitalWrite(ledPin, HIGH); // Turn on the light (LED)

} else { // If it is light (LDR value is high)

digitalWrite(ledPin, LOW); // Turn off the light

delay(1000); // Delay for 1 second before the next reading

Explanation of the Code:

 The LDR sensor reads the amount of light falling on it, outputting an analog value between 0
(dark) and 1023 (bright).
 The analogRead() function is used to read the value from the LDR, which is then compared to a
threshold.

 If the light level is below the threshold (i.e., it is dark), the LED (simulating the light) is turned on.
If the light level is above the threshold (i.e., it is bright), the LED is turned off.

 The serial monitor is used for debugging to monitor the LDR readings in real-time.

4. Run and Test (15 minutes):

 Start the simulation.

 Observe the LDR value being printed to the serial monitor.

 Simulate light changes by adjusting the environment in the simulation (e.g., dimming the virtual
light).

 Verify that the LED (light) turns on when it gets dark and off when the environment is bright.

5. Discussion and Reflection (10 minutes):

 Real-Time Control:
Discuss how the system reads sensor data and makes real-time decisions to control the LED
based on environmental conditions.

 Automation and Efficiency:


Reflect on how this type of automation can be used in real-world applications, such as street
lighting or home lighting systems, to save energy and ensure lights are only on when necessary.

 Sensor Calibration:
Discuss how the LDR's behavior might vary with different lighting conditions and materials in the
environment, and how adjusting the threshold could help tailor the system to different settings.

 Extensions:
Suggest possible extensions to the system:

o Use an actual light sensor (e.g., TSL2561) for more accurate readings.

o Implement a delay or hysteresis to prevent the light from constantly flickering as the
ambient light changes around the threshold.

o Integrate a real-time clock (RTC) to make the light control system time-dependent (e.g.,
turning the light on at dusk and off at dawn).

o Add a display (LCD or OLED) to show the current light level in real-time.

This exercise teaches students how to design an automation system that responds to environmental
changes, such as light levels. It reinforces the use of light sensors, thresholds, and actuators while
introducing concepts like energy-saving and real-time control, which are applicable in IoT and smart
home systems.

You might also like