0% found this document useful (0 votes)
414 views

Arduino Light Sensor Circuit Using LDR

Uploaded by

Ayoub Rajawi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
414 views

Arduino Light Sensor Circuit Using LDR

Uploaded by

Ayoub Rajawi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

03/02/2021 Arduino Light Sensor Circuit using LDR

ARDUINO (HTTPS://CIRCUITDIGEST.COM/ARDUINO-PROJECTS)

Arduino Light Sensor Circuit using LDR


(/microcontroller-projects/arduino-light-sensor-using-
ldr)
By (page_author.html)Pankaj Khatri (/users/pankaj-khatri)  Mar 16, 2018 2

Arduino Light Sensor Circuit using LDR

We all want our home appliances to be controlled automatically based on some conditions and that's called Home
automation (https://circuitdigest.com/home-automation-projects). Today we are going to control the light based of
darkness outside, the light turns ON automatically when it is dark outside and turns off when it gets bright. For this, we
need a light sensor to detect the light condition and some circuitry to control the Light sensor. It’s like Dark and light
Detector circuit (https://circuitdigest.com/electronic-circuits/dark-and-light-indicator) but this time we are using Arduino to
get more control over light.

In this circuit, we are making a Light Sensor using LDR with Arduino to control a bulb/CFL as per light condition of the
room or outside area.

Material Required
https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 1/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Arduino UNO
LDR (Light Dependent Resistor)
Resistor (100k-1;330ohm-1)

LED - 1
Relay module - 5v
Bulb/CFL
Connecting wires
Breadboard

Circuit Diagram

(/fullimage?

i=circuitdiagram_mic/Arduino-Light-Sensor-Circuit-diagram-using-LDR_0.png)

LDR

LDR is Light Dependent Resistor. LDRs are made from semiconductor materials to enable them to have their light-sensitive
properties. There are many types but one material is popular and it is cadmium sul de (CdS). These LDRs or PHOTO
RESISTORS works on the principle of “Photo Conductivity”. Now what this principle says is, whenever light falls on the

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 2/11
03/02/2021 Arduino Light Sensor Circuit using LDR

surface of the LDR (in this case) the conductance of the element increases or in other words, the resistance of the LDR falls
when the light falls on the surface of the LDR. This property of the decrease in resistance for the LDR is achieved because it
is a property of semiconductor material used on the surface.

We previously made many Circuits using LDR (https://circuitdigest.com/tags/ldr), which use LDR to automate the lights
according to requirement.

 
Working of LDR controlled LED using Arduino

As per the circuit diagram, we have made a voltage divider circuit (https://circuitdigest.com/calculators/voltage-divider-
calculator) using LDR and 100k resistor. The voltage divider output is feed to the analog pin of the Arduino. The analog Pin
senses the voltage and gives some analog value to Arduino. The analog value changes according to the resistance of LDR.
So, as the light falls on the LDR the resistance of it get decreased and hence the voltage value increase.

Intensity of light ↓ - Resistance↑ - Voltage at analog pin↓ - Light turns ON

As per the Arduino code, if the analog value falls below 700 we consider it as dark and the light turns ON. If the value
comes above 700 we consider it as bright and the light turns OFF.

Code Explanation:

Complete Arduino Code and Demonstration Video is given at the end of this project.

Here, we are de ning the Pins for Relay, LED and LDR.

#define relay 10
int LED = 9;
int LDR = A0;

Setting up the LED and Relay as Output pin, and LDR as input pin.

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 3/11
03/02/2021 Arduino Light Sensor Circuit using LDR

pinMode(LED, OUTPUT);
pinMode(relay, OUTPUT);
pinMode(LDR, INPUT);


Reading the voltage analog value through the A0 pin of the Arduino. This analog Voltage will be increased or decreased
according to the resistance of LDR.

int LDRValue = analogRead(LDR);

Giving the condition for dark and bright. If the value is less than 700 then it is dark and the LED or Light turns ON. If the
value is greater than 700 then it is bright and the LED or light turns OFF.

if (LDRValue <=700)
{
digitalWrite(LED, HIGH);
digitalWrite(relay, HIGH);
Serial.println("It's Dark Outside; Lights status: ON");
}
else
{
digitalWrite(LED, LOW);
digitalWrite(relay, LOW);
Serial.println("It's Bright Outside; Lights status: OFF");
}

Controlling Relay using LDR with Arduino

(/fullimage?

i=inlineimages/u/Arduino-Light-Sensor-Circuit-diagram-using-LDR-and-Relay.png.png)

Instead of controlling an LED according to the brightness and darkness, we can control our home lights or any electrical
equipment. All we have to do is connect a relay module and set the parameter to turn ON and OFF the any AC appliance
according to the intensity of the light. If the value falls below 700, which means it Dark, then the relay operates and the
lights turns ON. If the value is greater than 700, which means its day or bright, then the relay will not operate and the lights
remain OFF. Learn more about relay here (https://circuitdigest.com/article/relay-working-types-operation-applications) and
how to connect an AC appliance to relay (https://circuitdigest.com/electronic-circuits/automatic-room-lights-using-pir-
sensor-and-relay).

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 4/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Also, check:

Automatic Street Light Controller Circuit Using Relay and LDR (https://circuitdigest.com/electronic-
circuits/automatic-street-light-controller-circuit)
Automatic Staircase Light (https://circuitdigest.com/microcontroller-projects/automatic-staircase-lighting-using-
avr-microcontroller)
Raspberry Pi Emergency Light (https://circuitdigest.com/microcontroller-projects/raspberry-pi-emergency-lamp)

Code

#de ne relay 10

int LED = 9;

int LDR = A0;

void setup() 

Serial.begin(9600);

pinMode(LED, OUTPUT);

pinMode(relay, OUTPUT);

pinMode(LDR, INPUT);

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 5/11
03/02/2021 Arduino Light Sensor Circuit using LDR

void loop() {

int LDRValue = analogRead(LDR);

Serial.print("sensor = ");

Serial.print(LDRValue);

if (LDRValue <=700) 

digitalWrite(LED, HIGH);

digitalWrite(relay, HIGH);

Serial.println("It's Dark Outside; Lights status: ON");

else 

digitalWrite(LED, LOW);

digitalWrite(relay, LOW);

Serial.println("It's Bright Outside; Lights status: OFF");

Video

Arduino Light Sensor using LDR

TAGS RELAY (/TAGS/RELAY) LDR (/TAGS/LDR) AC LIGHTS (/TAGS/AC-LIGHTS) ARDUINO (/TAGS/ARDUINO)

ARDUINO UNO (/TAGS/ARDUINO-UNO) LIGHT INTENSITY (/TAGS/LIGHT-INTENSITY)

Get Our Weekly Newsletter!


Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Email Address *

Name

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 6/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Country
United States of America 
Subscribe

RELATED CONTENT

(/electronic-circuits/simple-motion-detector-circuit-using-555-timer-and-relay-

to-control-ac-loads)
Build a Simple Motion Detector Circuit using 555 Timer to Control AC Loads (/electronic-circuits/simple-motion-
detector-circuit-using-555-timer-and-relay-to-control-ac-loads)

(/case-studies/why-its-important-to-set-date-and-time-in-numerical-relays)

Why is it Important to Set Date and Time in Numerical Relays? (/case-studies/why-its-important-to-set-date-and-time-in-


numerical-relays)

(/case-studies/importance-of-relay-coordination-in-process-industries)

Importance of Relay Coordination in Process Industries (/case-studies/importance-of-relay-coordination-in-process-


industries)

(/case-studies/importance-of-relay-selection-in-grid-connected-industries)

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 7/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Importance of Relay Selection in Grid-Connected Industries (/case-studies/importance-of-relay-selection-in-grid-


connected-industries)

(/microcontroller-projects/automatic-bottle- lling-system-using-arduino)

Automatic Bottle Filling System using Arduino (/microcontroller-projects/automatic-bottle- lling-system-using-arduino)

(/case-studies/dont-use-your-numerical-relay-like-electromagnetic-relay)

Don't use your Numerical Relay like Electromechanical Relay (/case-studies/dont-use-your-numerical-relay-like-


electromagnetic-relay)

(/case-studies/what-could-cause-repeated-relay-failures-in-chemical-plants)

What could cause repeated relay failures in a chemical plant? (/case-studies/what-could-cause-repeated-relay-failures-


in-chemical-plants)

(/electronic-circuits/relay-driver-module-circuit-pcb)

4-Channel Relay Driver Circuit and PCB Design (/electronic-circuits/relay-driver-module-circuit-pcb)

 PREVIOUS POST
Arduino Ohm Meter (https://circuitdigest.com/microcontroller-projects/arduino-ohm-meter)

NEXT POST 

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 8/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Blinking LED Sequence with MSP430G2: Using Digital Read/Write Pins (https://circuitdigest.com/microcontroller-
projects/blinking-led-sequence-with-msp430-digital-read-write-pins)

COMMENTS

Pragathi k s
Jul 29, 2018

Good
Log in (/user/login?destination=node/1626%23comment-form) or register (/user/register?
destination=node/1626%23comment-form) to post comments

Rahul Gupta (/users/rahul-gupta)


Sep 30, 2018
(/users/rahul-gupta)
can u show the connections for the bulb and an external battery with the same
Log in (/user/login?destination=node/1626%23comment-form) or register (/user/register?
destination=node/1626%23comment-form) to post comments
circuit

LOG IN (/USER/LOGIN?DESTINATION=NODE/1626%23COMMENT-FORM) OR REGISTER (/USER/REGISTER?


DESTINATION=NODE/1626%23COMMENT-FORM) TO POST COMMENT

NEWS ARTICLES PROJECTS

Easy-To-Use Onion Tau Camera Offers an Affordable Entry Point to LIDAR-Like 3D Mapping (/news/easy-to-use-
onion-tau-camera-offers-affordable-entry-point-to-lidar-3d-mapping)

(/news/easy-
to-use-onion-
tau-camera-
offers-
affordable-
entry-point-to-
lidar-3d-
mapping)

New High-Temperature Snubber less TRIACs can Save Space and Boost Reliability (/news/new-high-temperature-
snubber-less-triacs-can-save-space-and-boost-reliability)

(/news/new-
high-
temperature-
snubber-less-
triacs-can-
save-space-

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 9/11
03/02/2021 Arduino Light Sensor Circuit using LDR

and-boost-
reliability)

High-Speed Inductive Position Sensor for Easy Customization and High Accuracy in Automotive Applications
(/news/high-speed-inductive-position-sensor-for-easy-customization-high-accuracy-in-automotive-applications)

(/news/high-
speed-
inductive-
position-
sensor-for-
easy-
customization-
high-
accuracy-in-
automotive-
applications)

250 kHz IMC-Hall Current Sensor for High Accuracy and Diagnostics in Inverters/Converters and Battery
Applications (/news/250-khz-imc-hall-current-sensor-for-high-accuracy-and-diagnostics-of-inverters-converters-
and-battery-applications)
(/news/250-
khz-imc-hall-
current-
sensor-for-
high-
accuracy-and-
diagnostics-
of-inverters-
converters-
and-battery-
applications)

New Road Noise Cancellation (RNC) Sensors with A2B Technology to Combat Unwanted Road, Wind, and HVAC
Car Noise (/news/new-road-noise-cancellation-rnc-sensors-with-a2b-technology-to-combat-unwanted-road-wind-
and-hvac-car-noise)
(/news/new-
road-noise-
cancellation-
rnc-sensors-
with-a2b-
technology-
to-combat-
unwanted-
road-wind-
and-hvac-car-
noise)

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 10/11
03/02/2021 Arduino Light Sensor Circuit using LDR

Connect with us on social media and stay updated with latest news, articles and projects!

 
     (https://www.linkedin.com/company/circ

(https://www.facebook.com/circuitdigest/)
(https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IP
(https://www.instagram.com/circuit_digest/)
(https://www.pinterest.com/circuitdigest/)
digest/)

CATEGORIES

Embedded Electronics (https://circuitdigest.com/embedded)

Power Electronics (https://circuitdigest.com/power-electronics)

Analog Electronics (https://circuitdigest.com/analog-electronics)

Internet of Things (https://circuitdigest.com/internet-of-things)

Audio Electronics (https://circuitdigest.com/audio-electronics)

Electric Vehicles (https://circuitdigest.com/electric-vehicles)

Events (https://circuitdigest.com/events)

POPULAR

ROBOTICS (/ROBOTICS-PROJECTS) 555 CIRCUITS (/555-TIMER-CIRCUITS) ARDUINO PROJECTS (/ARDUINO-PROJECTS)

RASPBERRY PI PROJECTS (/SIMPLE-RASPBERRY-PI-PROJECTS-FOR-BEGINNERS)

ELECTRONICS NEWS (HTTPS://CIRCUITDIGEST.COM/NEWS) ELECTRONICS FORUM (HTTPS://CIRCUITDIGEST.COM/FORUMS)

CALCULATORS (HTTPS://CIRCUITDIGEST.COM/CALCULATORS)

NEWSLETTER

Sign Up for Latest News

Enter your email

Subscribe

Copyright © 2020 Circuit Digest (http://circuitdigest.com/). All rights reserved.

Privacy Policy (http://circuitdigest.com/privacy-policy) | Cookie Policy (https://circuitdigest.com/cookie-policy) | Terms of Use


(https://circuitdigest.com/terms-of-use) | Contact Us (http://circuitdigest.com/contact) | Advertise (http://circuitdigest.com/advertise)

https://circuitdigest.com/microcontroller-projects/arduino-light-sensor-using-ldr 11/11

You might also like