Close Menu
Circuit of Things
  • Home
  • About Us
  • Contact Us
  • 3D Print
  • Shop Now !
  • Projects
    • Raspberry Pi Projects
    • Arduino Projects
    • ESP8266 Projects
    • ESP32 Projects
    • IoT Tutorials
    • Sensors & Modules
    • IoT Basics
  • KSP Tools

Get Free Tutorials & Discounts!

Subscribe for the latest IoT tutorials and exclusive KSP Electronics discount codes.

Instagram WhatsApp
  • Terms and Conditions
  • Disclaimer
  • Privacy Policy
  • Contact Us
Circuit of Things Circuit of Things
  • Home
  • About Us
  • Contact Us
  • 3D Print
  • Shop Now !
  • Projects
    • Raspberry Pi Projects
    • Arduino Projects
    • ESP8266 Projects
    • ESP32 Projects
    • IoT Tutorials
    • Sensors & Modules
    • IoT Basics
  • KSP Tools
Hire us
Circuit of Things
Home»Arduino Projects»LDR Light Sensor with Arduino: Auto Night Light Project
Arduino Projects

LDR Light Sensor with Arduino: Auto Night Light Project

Sai Preetham KoyyalaBy Sai Preetham KoyyalaMay 4, 2026Updated:May 7, 2026No Comments2 Mins Read
Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
Share
Facebook Twitter LinkedIn Pinterest Email
Contents
  • Introduction
  • Components Needed
  • Circuit: Voltage Divider
  • Project 1: Read Light Level
  • Project 2: Automatic Night Light
  • Project 3: Brightness-Controlled Dimming
  • Conclusion

Introduction

A Light Dependent Resistor (LDR), also called a photoresistor, changes its resistance based on the amount of light hitting it. In bright light, resistance drops to a few hundred ohms. In darkness, it can rise to several megaohms. In this tutorial, we use this property to build an automatic night light that turns on when it gets dark.

Components Needed

  • Arduino Uno
  • LDR (photoresistor)
  • 10k-ohm resistor
  • LED and 330-ohm resistor
  • Breadboard and jumper wires

Circuit: Voltage Divider

The LDR and 10k-ohm resistor form a voltage divider. As light decreases, LDR resistance increases, raising the voltage at the midpoint (analog pin A0). We read this value and use it to determine when to turn on the LED.

Project 1: Read Light Level

#define LDR_PIN A0
void setup() { Serial.begin(9600); }
void loop() {
  int lightLevel = analogRead(LDR_PIN);
  Serial.println("Light Level: " + String(lightLevel));
  delay(500);
}

Project 2: Automatic Night Light

#define LDR_PIN A0
#define LED_PIN 9
#define THRESHOLD 500 // Adjust based on your environment
void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
}
void loop() {
  int light = analogRead(LDR_PIN);
  if (light < THRESHOLD) {
    digitalWrite(LED_PIN, HIGH); // Dark - turn LED on
  } else {
    digitalWrite(LED_PIN, LOW);  // Bright - turn LED off
  }
  Serial.println("LDR: " + String(light));
  delay(200);
}

Project 3: Brightness-Controlled Dimming

Instead of simply ON/OFF, this project smoothly dims the LED inversely proportional to ambient light using PWM.

#define LDR_PIN A0
#define LED_PIN 9
void setup() { pinMode(LED_PIN, OUTPUT); }
void loop() {
  int light = analogRead(LDR_PIN);
  int brightness = map(light, 0, 1023, 255, 0);
  analogWrite(LED_PIN, brightness);
  delay(100);
}

Conclusion

The LDR is a simple but powerful sensor. Combine it with a relay module instead of an LED and you have a fully automatic street light controller!

Related Tutorials

  • Get Started with Arduino: A Beginner’s Guide to the World of Electronics
  • How to Power Your Arduino & ESP32 Projects Properly
  • How to Build a DIY Robotic Hand using Flex Sensors and Arduino
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleESP32 Bluetooth Tutorial: Wireless Serial Communication with Arduino IDE
Next Article ESP32 OTA Updates: Program Your Board Over Wi-Fi with Arduino IDE
Sai Preetham Koyyala
  • Website
  • Facebook
  • X (Twitter)
  • Instagram
  • LinkedIn

Hello, I am Sai Preetham Koyyala. I'm an electronics engineer by profession, a DIY enthusiast by passion. ESP32 and Arduino are the main topics of my work.

Related Posts

IoT Tutorials

How to Build a DIY Robotic Hand using Flex Sensors and Arduino

May 6, 2026
IoT Tutorials

How to Build a DIY Robotic Hand using Flex Sensors and Arduino

May 6, 2026
IoT Basics

How to Power Your Arduino & ESP32 Projects Properly

May 6, 2026
Add A Comment
Leave A Reply Cancel Reply


⚡

Circuit of Things

Free IoT tutorials & electronics projects — powered by KSP Electronics.

📸 Instagram 💬 Community
✓ Official Partner Store

Everything for Your
Next IoT Build

Boards, sensors, modules & kits — fast delivery across India.

ESP32 Arduino Sensors Raspberry Pi 3D Print
🛒 Shop KSP Electronics →
Top Posts

Raspberry Pi: How to Control a DC Motor with L298N and PWN on a Web Server

July 14, 2023

Step-by-Step Guide: Interface DHT11 and DHT22 Sensors with ESP32

May 6, 2026

Esp8266 / NodeMCU Pinout: A Comprehensive Guide for Beginners

June 25, 2023
Available for Projects

Hire Us for IoT Development

End-to-end solutions for your needs:

  • → ESP32 & Embedded Systems
  • → LoRaWAN & Cloud Dashboards
  • → Custom Hardware Design
  • → IoT Product Prototyping
View Services →

Get Free Tutorials & Discounts!

Subscribe to get the latest IoT tutorials and exclusive hardware discount codes for KSP Electronics delivered directly to your inbox.

Follow Us
  • Instagram
  • Telegram
About Circuit of Things

We are a community-driven engineering platform dedicated to IoT, Robotics, and DIY electronics tutorials.

Proudly partnered with KSP Electronics.

Quick Links
  • Home
  • ESP32 Projects
  • Arduino Projects
  • IoT Tutorials
  • Sensors & Modules
  • Shop on KSP Electronics
  • Electro Calc
Legal & Support
  • Terms and Conditions
  • Disclaimer
  • Privacy Policy
  • Contact Us
📩

Get Free Tutorials & Discounts!

Subscribe for IoT tutorials and exclusive KSP discount codes.

Subscription Form


By subscribing, you agree to our Privacy Policy. No spam, ever.

X (Twitter) Instagram YouTube WhatsApp
  • Terms and Conditions
  • Disclaimer
  • Privacy Policy
  • Contact Us
© 2026 Circuit of Things. Designed by Sai Preetham Koyyala.

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