SupportContact
Allpanga
•Home•Marketplace•Blogs•Nexus HubLive•Origins
Students studying
Students outdoors
school

Allpanga

The ultimate peer-to-peer marketplace and community hub designed exclusively for students to trade, learn, and grow together.

Our LocationAllpanga HQ — View on Google Maps

Explore

  • Marketplace
  • Student Blogs
  • Nexus Hub
  • How It Works

Support

  • Help Center
  • Contact Us
  • Community Guidelines
  • Selling Guidelines
  • Origins

Legal

  • Privacy Policy
  • Terms of Service
  • Community Guidelines

© 2026 ALLPANGA. All rights reserved.

Privacy PolicyTerms of Service
How to Build an Automatic Light Sensor Using Arduino and LDR
Electronics

How to Build an Automatic Light Sensor Using Arduino and LDR

MS
M Saeed Baig MSBAIG
calendar_todayJul 22, 2026
schedule3 min read
visibility 0favorite0chat_bubble 0
Homechevron_rightBlogschevron_rightElectronicschevron_rightHow to Build an Automatic Light Sensor Using Arduino and LDR
MS
M Saeed Baig MSBAIG
Student CreatorElectronics

Sharing practical student projects and applied learning experiences.

2 Works
0 Followers

DIY automatic light sensor

Automation projects are a great way to step into the world of electronics and microcontrollers. In this tutorial, you will learn step-by-step how to build an automatic light-detecting circuit using an Arduino Uno, a Light Dependent Resistor (LDR) module, and an LED indicator on a breadboard.

This simple DIY project is perfect for beginners who want to understand how sensors interact with microcontrollers to control output devices like LEDs or streetlights.




How It Works

The core concept behind this project is simple:




  1. LDR Sensor: Measures the ambient light intensity in the room. When light drops below a certain threshold (darkness), the module's signal output changes.
  2. Arduino Uno: Processes the signal received from the LDR module.
  3. LED Output: The Arduino triggers the LED to turn ON when it detects darkness and turns it OFF when there is sufficient light.

Components Required

To follow along with this build, you will need the following hardware components:

Component Quantity Description Arduino Uno1Microcontroller board LDR Module1Light sensor module with digital outputLED1Any 5mm LED (e.g., Red or Green)Breadboard1Grid breadboard for solderless connections Jumper Wires Several Male-to-Male / Male-to-Female jumper wires




Circuit Connection Step-by-Step

Follow these steps carefully to wire your circuit correctly:




Step 1: Power the Breadboard Rails

  • Connect the 5V pin of the Arduino to the positive ($+$) power rail of the breadboard.
  • Connect the GND pin of the Arduino to the negative ($-$) ground rail of the breadboard.

Step 2: Connect the LDR Sensor Module

  • VCC Pin: Connect to the $+5\text{V}$ power rail.
  • GND Pin: Connect to the ground rail.
  • DO (Digital Out) Pin: Connect to Digital Pin D3 on the Arduino.

Step 3: Insert the LED

  • Place the LED across two separate rows on the breadboard grid.
  • Connect the Anode (+) (longer leg) to Digital Pin D2 on the Arduino.
  • Connect the Cathode (-) (shorter leg) to the ground rail (or through a $220\,\Omega$ resistor to ground).

Arduino Code Example

Upload the following code to your Arduino Uno using the Arduino IDE:

C++



// Pin Definitions
const int ldrPin = 3;  // LDR Signal connected to D3
const int ledPin = 2;  // LED connected to D2

void setup() {
  pinMode(ldrPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int ldrStatus = digitalRead(ldrPin);

  // If dark (LDR signal HIGH or LOW depending on module trigger)
  if (ldrStatus == HIGH) {
    digitalWrite(ledPin, HIGH); // Turn LED ON
  } else {
    digitalWrite(ledPin, LOW);  // Turn LED OFF
  }
}



Testing Your Setup

  1. Connect your Arduino to your computer via USB cable.
  2. Upload the code using the Arduino IDE.
  3. Cover the LDR sensor with your hand to simulate darkness.
  4. Result: The LED should turn ON automatically when light is blocked and turn OFF when light returns!

Conclusion

Congratulations! You have successfully built an automatic light sensor project using Arduino. This basic concept is widely used in real-world applications like automatic street lights, smart home automation, and security systems.

Have questions or want to try building this project with an analog LDR instead? Drop your comments below!



Blog Image

Topic:
#Arduino Uno breadboard tutorial#DIY automatic light sensor#How to connect LDR to Arduino#Arduino LDR sensor project
Share:

Comments (0)

U
chat_bubble

No comments yet. Be the first to start the discussion.

MS
M Saeed Baig MSBAIG@allpanga.sgi

Sharing practical student projects and applied learning experiences.

Posts

2

Followers

0

0
View Full Profile

In this blog

01How It Works02Components Required03Circuit Connection Step-by-Step04Step 1: Power the Breadboard Rails05Step 2: Connect the LDR Sensor Module06Step 3: Insert the LED07Arduino Code Example08Testing Your Setup
Appreciate work
0
Share project

Quick discussion

Related Blogs

How to Connect LCD to Arduino
How to Connect LCD to Arduino
How to Safely Connect and Blink an LED with Arduino Uno
How to Safely Connect and Blink an LED with Arduino Uno

More by M

Electronics

How to Safely Connect and Blink an LED with Arduino Uno