Arduino B.Tech/Diploma Beginner

How to use LDR Sensor Module with Arduino

Interfacing of an LDR (Light Dependent Resistor) or Photoresistor Sensor Module with the Arduino UNO Code for Dark Activated Light project

  • Suitable forB.Tech/Diploma Arduino students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this tutorial, we will learn interfacing of
LDR Sensor
(Photoresistor) with
Arduino UNO
R4 Minima Board. A LDR Module also known as
Light Dependent Resistor
or
Photoresistor
is a device that can detect the
intensity of light
in the environment. It is widely used in various applications such as
automatic lighting
systems, security devices, and environmental monitoring.
The LDR Sensor Module consists of a
photoresistor
whose resistance varies with the intensity of light falling on it. When interfaced with an
Arduino
, it enables the board to detect and respond to changes in
light levels
. This can be useful for projects that require the Arduino to activate or deactivate certain functions based on
ambient light
conditions.
Throughout this guide, we will cover the essentials of connecting the
LDR Sensor Module
to an
Arduino UNO
board, writing the
code
to read light intensity levels, and implementing basic
applications
like Dark Activated Light.
Bill of Materials
For this tutorial I am using the
SunFounder Arduino Starter Kit
which has 90+ components.
Here are the list of components I am using from this Kit.
S.N.
Components
Quantity
Purchase Links

Arduino UNO R4/R3 Board

Amazon
AliExpress

LDR Sensor Module

Amazon
AliExpress

LED

Amazon
AliExpress
SunFounder

220-ohm Resistor

Amazon
AliExpress
SunFounder

Connecting Wires

Amazon
AliExpress
SunFounder

Type C USB Cable

Amazon
AliExpress

Breadboard

Amazon
AliExpress
SunFounder
LDR Sensor Module (Light Dependent Resistor)
A photoresistor module serves as a light intensity detection device in various environments. It has multiple uses, including adjusting a device’s brightness, differentiating between day and night, or triggering a light switch.
At the core of this module lies the photoresistor, a resistor whose value changes with light exposure. As light intensity increases, the resistance of a photoresistor diminishes, showcasing photoconductivity.
In practical applications, a photoresistor is integral to circuits sensitive to light, enabling both light-activated and dark-activated switches by functioning as a resistive semiconductor. Its resistance can vary significantly based on light conditions, reaching up to several megaohms (MΩ) in darkness, but dropping to just a few hundred ohms in bright light.
Below is the electronic symbol representing a photoresistor.
Working of LDR (Light Dependent Resistor)
The working principle of a Light Dependent Resistor (LDR) sensor is based on the change in its resistance in response to varying light intensities. An LDR primarily consists of a photoresistor, a component whose resistance varies with the amount of light it is exposed to.
In low light conditions, the photoresistor has a high resistance, allowing minimal electrical current to pass through. As the intensity of light increases, the resistance of the photoresistor decreases, allowing more current to flow. This characteristic enables the LDR to act as a light-sensitive device.
The LDR’s ability to alter its resistance with changing light conditions is leveraged in various applications, where it acts as a passive sensor, responding to environmental light changes. This response is purely based on the photoresistive properties of the material used in the LDR, with no need for any external power source to modify its sensitivity. The simplicity and effectiveness of this principle make LDRs widely used in circuits that require light sensing capabilities.
LDR Sensor Module Schematic
Features of LDR Sensor Module
Using sensitive photosensitive resistance sensor
The comparator output signal is clean, good waveform, driving ability, more than 15mA
With adjustable potentiometer to adjust the brightness of the light detection
The working voltage is 3.3V-5V
The output form: DO digital switching outputs (0 and 1) and AO analog voltage output
A fixed bolt holes for easy installation
Using a wide voltage LM393 comparator
PCB Size: 3.1cm x 1.4cm
Pinout of LDR Sensor Module
The LDR Sensor Module has 4 pins.
VCC
: positive power supply 3.3-5V
GND
: power supply is negative
DO
: TTL switching signal output
AO
: Analog output
Interfacing LDR Sensor Module (Photoresistor) with Arduino
Now let’s interface the LDR Sensor Module with Arduino to make a Dark Activated Light System. Here is the simple connection diagram.
Begin by connecting the LDR sensor’s VCC pin to the 5V output on the Arduino for power. Then, connect the GND pin of the LDR to one of the GND pins on the Arduino. The finally connect the Analog Output Pin (A0) to A0 of Arduino.
For indication, we are using the LED connected to digital pin D2 of Arduino via 220-0hm resistor.
Source Code/Program
The coding part of the project is written in Arduino. Lets take a look at the code for interfacing LDR Sensor Module (Photoresistor) with Arduino UNO. The code is very simple.
This project is a light control switch system. The main idea is to use a LDR sensor module to detect the ambient light level and, based on this detection, control a LED. If the ambient light is below a certain threshold, the LED is switched on. Conversely, if the ambient light is above the threshold, the LED is switched off.

// Define pin numbers
const
int
ledPin
=

;
// LED connected to digital pin 8
const
int
ldrPin
=
A0
;
// LDR connected to analog pin A0
void
setup
(
)
{
pinMode
(
ledPin
OUTPUT
)
;
// Set the LED pin as output
Serial
begin
(
9600
)
;
// Start serial communication at 9600 bps
}
void
loop
(
)
{
int
ldrValue
=
analogRead
(
ldrPin
)
;
// Read the value from the LDR
Serial
println
(
ldrValue
)
;
// Print the value to the serial monitor
// Assuming a lower value means more light
if
(
ldrValue
>

)
{
digitalWrite
(
ledPin
HIGH
)
;
// Turn the LED on
}
else
{
digitalWrite
(
ledPin
LOW
)
;
// Turn the LED off
}
delay
(

)
;
// Wait for half a second
}
In this code you need to setup the threshold value of LDR based on your room or environment light working conditions.
Testing the LDR Arduino Project Working
After uploading the code to the Arduino UNO Board, the device is ready for testing.
To test it, place the LDR in room filled with light. If the ambient light is above the threshold, the LED doesn’t turn ON.
If the ambient light is below the threshold, the LED is switched on. You may put your finger on LDR sensor to block the light falling on it.
This is how you can use LDR Sensor Module (Photoresistor) with Arduino to make Dark Activated Light.
Some Projects using LDR Sensor Module
Laser Light Security System
Dark Activated Night Lamp
Dark Activated 220V AC Lamp
Automatic Street Light
Solar Tracking Project

Technologies used

ArduinoBLE

Hardware components

  • Arduino
  • LDR

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.