Monday, July 21, 2025

LED Auto ON/OFF Using LDR and Arduino | Light Sensor Project for Beginners

Have you ever wanted a light that turns ON automatically when it’s dark and OFF when it’s bright? In this beginner-friendly project, we’ll show you how to build a simple light-sensitive LED control system using an Arduino and an LDR (Light Dependent Resistor) module.

Simple LED Auto ON/OFF

๐Ÿ“ฆ What You’ll Need

To get started, you will need the following components:

Components required for this tutorial

✅ Arduino UNO × 1
✅ 3-pin LDR Module × 1
✅ Jumper Wires × 1
✅ USB cable for Arduino × 1
✅ Resistor 220ฮฉ × 1
✅ Breadboard × 1

๐Ÿ› ️ Circuit Wiring

Here’s how to connect each component to the Arduino:

3-pin LDR module wiring

3-pin LDR Module 
✅ VCC → 5V on Arduino
✅ GND → GND on Arduino
✅ A0 → Analog pin A0 on Arduino

LED and resistor wiring

LED and Resistor
✅ LED Anode (long leg) → Digital pin 9 on Arduino
LED Cathode (short leg) → 220ฮฉ resistor → GND on Arduino

The connection between components and Arduino

๐Ÿ’ป Uploading the Code

After wiring everything up, connect the Arduino to your computer using a USB cable.  Then, upload the following code, or you can download the code HERE.
int ldrPin = A0;
int ledPin = 9;
int threshold = 500;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int ldrValue = analogRead(ldrPin);
  Serial.println(ldrValue);

  if (ldrValue < threshold) {
    digitalWrite(ledPin, HIGH);  // It's dark, turn on LED
  } else {
    digitalWrite(ledPin, LOW);   // It's bright, turn off LED
  }

  delay(200);
}

Open Arduino IDE and copy-paste the code

The value 500 is the light threshold. You can check the actual LDR readings via the Serial Monitor and adjust this number depending on your room lighting conditions.

๐Ÿงช Test the System

In low light, the LED should turn ON.

In bright light, the LED should turn OFF.

๐Ÿ“Œ Conclusion

This project is a simple yet powerful introduction to sensor-based automation using Arduino. By combining a Light Dependent Resistor (LDR) with an LED, you’ve created a system that can react to ambient light—automatically turning the light ON in the dark and OFF in bright conditions.

๐ŸŽฅ Watch the Full Video Tutorial


๐Ÿ”” If you found this guide helpful, share it with fellow makers! For more tutorials, subscribe to our YouTube channel and follow us on social media. ๐Ÿš€

#Arduino #DIYElectronics #LDREngineering #SmartLighting #BeginnerProject #IoT #Maker

No comments:

Post a Comment