Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » How to use LDR Sensor Module with Arduino
Arduino Projects

How to use LDR Sensor Module with Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:February 2, 20255 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
How to use LDR Sensor Module with Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

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.ComponentsQuantityPurchase Links
1Arduino UNO R4/R3 Board1Amazon | AliExpress
2LDR Sensor Module1Amazon | AliExpress
3LED1Amazon | AliExpress | SunFounder
4220-ohm Resistor1Amazon | AliExpress| SunFounder
5Connecting Wires10Amazon | AliExpress | SunFounder
6Type C USB Cable1Amazon | AliExpress
7Breadboard1Amazon | 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.

LDR Light Dependent Resistor Photoresistor

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

LDR Sensor Module Schematic Diagram

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.

LDR Sensor Pinout

  • 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.

LDR Sensor Module Arduino Connection

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.

LDR Sensor Photoresistor Module 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Define pin numbers
const int ledPin = 2;      // 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 > 600)
  {  
    digitalWrite(ledPin, HIGH);  // Turn the LED on
  }
  else
  {
    digitalWrite(ledPin, LOW);   // Turn the LED off
  }
 
  delay(500);  // 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
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterfacing MPU6050 Accelerometer & Gyroscope with Arduino
Next Article How to use IR Sensor Module with Arduino – Simple Guide

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
  • IoT Based Patient Health Monitoring on ESP32 Web Server
    IoT Based Patient Health Monitoring on ESP32 Web Server
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.