๐Ÿ”† Project Title: Automatic Night Lamp using LDR and Arduino Nano

๐Ÿ”† Project Title: Automatic Night Lamp using LDR and Arduino Nano

๐Ÿ” Project Overview:

This project automatically turns ON an LED when it is dark and OFF when there is light. It uses a Light Dependent Resistor (LDR) to detect the surrounding brightness and an Arduino Nano to control the LED based on the sensorโ€™s readings. Itโ€™s a simple and practical automation system often used in night lamps and street lights.

โš™๏ธ Circuit Connection Table

ComponentPin 1 ConnectionPin 2 ConnectionNotes / Description
Arduino Nano5V pin โ†’ Breadboard + (red line)GND pin โ†’ Breadboard โ€“ (blue line)Provides power and ground rails
LDROne leg โ†’ Breadboard + (5V)Second leg โ†’ Node X (junction point)LDR detects light level
10kฮฉ ResistorOne leg โ†’ Node X (same as LDR 2nd leg)Other leg โ†’ Breadboard โ€“ (GND)Forms voltage divider with LDR
Jumper wireNode X โ†’ A0 pin on Nanoโ€”Sends analog voltage from divider to Arduino
LEDAnode (+ longer leg) โ†’ One end of 220ฮฉ resistorCathode (โ€“ shorter leg) โ†’ Breadboard โ€“ (GND)LED lights up in dark
220ฮฉ ResistorOne end โ†’ LED anode (+)Other end โ†’ D3 pin on NanoLimits current to LED
PowerBreadboard + โ†’ Arduino 5VBreadboard โ€“ โ†’ Arduino GNDCommon power connections

๐Ÿ” Circuit Summary

  • LDR + 10kฮฉ resistor form a voltage divider between 5V and GND.
  • The junction (Node X) sends varying voltage to A0 (light intensity reading).
  • Arduino checks this value:
    • If itโ€™s dark (high reading) โ†’ turns ON LED at D3.
    • If itโ€™s bright (low reading) โ†’ turns OFF LED.
Nano PinLDR Module Pin
5VVCC
GNDGND
A0AO
โ€”(DO not used)

๐Ÿ’ก Now add the LED part

ComponentConnection 1Connection 2Notes
LED (any color)Anode (+ longer leg) โ†’ One end of 220ฮฉ resistorCathode (โ€“ shorter leg) โ†’ GNDResistor limits current
220ฮฉ ResistorOther end โ†’ D3 pin on Arduino Nanoโ€”D3 will control the LED ON/OFF

So in simple words:

Nano D3 ----> 220ฮฉ resistor ----> LED anode (+)
LED cathode (โ€“) ----> GND

โš™๏ธ Final Arduino Nano Wiring Summary

Arduino Nano PinConnects ToComponent / Function
5VLDR Module VCCPower to sensor
GNDLDR Module GND & LED cathode (โ€“)Common ground
A0LDR Module AOReads light level
D3220ฮฉ resistor โ†’ LED anode (+)Controls LED output

๐ŸŒ™ Automatic Night Lamp using LDR Sensor Module + LED


Circuit

๐Ÿ’พ Complete Code



const int LIGHT_SENSOR_PIN = A0; // The Arduino Nano pin connected to light sensor's  pin
const int LED_PIN          = 2;  // The Arduino Nano pin connected to LED's pin
const int ANALOG_THRESHOLD = 500;

int analog_value;

void setup() {
  pinMode(LED_PIN, OUTPUT); // set arduino pin to output mode
}

void loop() {
  analog_value = analogRead(LIGHT_SENSOR_PIN); // read the input on analog pin

  if(analog_value < ANALOG_THRESHOLD)
    digitalWrite(LED_PIN, HIGH); // turn on LED
  else
    digitalWrite(LED_PIN, LOW);  // turn off LED
}


โš™๏ธ How to Test

  1. Upload the code to your Arduino Nano.
  2. Open Serial Monitor (Tools โ†’ Serial Monitor) and set baud = 9600.
  3. Note the readings in bright light and dark (cover the LDR).
  4. Adjust the line int threshold = 500; โ†’ Increase the number if your LED turns on too early,
    โ†’ Decrease it if LED doesnโ€™t turn on soon enough.

โœ… Expected Behavior

Light ConditionLDR Value (approx)LED State
Bright Light200โ€“400OFF
Dim / Dark600โ€“900ON

This Post Has One Comment

Leave a Reply