How to use LDR Sensor Module with Arduino (2024)

How to use LDR Sensor Module with Arduino (1)

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.

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.

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
How to use LDR Sensor Module with Arduino (2024)

References

Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 5465

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.