Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

How To Make DIY Automatic Night light using Arduino & LDR by WTC Zone

 How To Make DIY Automatic Night light using Arduino & LDR by WTC Zone

Creating an Automatic Night Light using an LDR (Light Dependent Resistor Module)LED, and Arduino is a straightforward project. The LED will turn on automatically when it’s dark and turn off when there’s sufficient light, providing a hands-free solution for low-light conditions.

Parts Required

  1. Arduino Uno
  2. LDR Module (with VCC, GND, and OUT pins)
  3. LED
  4. 220Ω Resistor (to limit current for the LED)
  5. Breadboard and Jumper Wires

Circuit Connections

  1. LDR Module:

    • VCC → 5V on Arduino.
    • GND → GND on Arduino.
    • OUT → Digital Pin 2 on Arduino (this will output HIGH in light and LOW in darkness).
  2. LED Circuit:

    • Anode (long leg) of LED → Digital Pin 9 on Arduino.
    • Cathode (short leg) of LED → 220Ω Resistor → GND on Arduino.

Video Link: - Click Here For Video

How To Make DIY Automatic Night light using Arduino & LDR by WTC Zone simple Circuit: -


How To Make DIY Automatic Night light using Arduino & LDR by WTC Zone Arduino Programming: -

Arduino IDE Program

Code for Automatic Night Light using LDR Module

This code reads the digital signal from the LDR module on Pin 2. When it’s dark, the module outputs LOW to Pin 2, triggering the LED to turn on.

// Pin Definitions
const int ldrPin = 2;    // LDR module output connected to Digital Pin 2
const int ledPin = 9;    // LED connected to Digital Pin 9

void setup() {
  pinMode(ldrPin, INPUT);     // Set LDR pin as input
  pinMode(ledPin, OUTPUT);    // Set LED pin as output
  Serial.begin(9600);         // Initialize serial monitor (optional for debugging)
}

void loop() {
  int ldrState = digitalRead(ldrPin); // Read the LDR module state
  Serial.println(ldrState);           // Print the LDR state for debugging (optional)
 
  if (ldrState == HIGH) {              // If it's dark
    digitalWrite(ledPin, HIGH);       // Turn LED on
  } else {                            // If it's light
    digitalWrite(ledPin, LOW);        // Turn LED off
  }
 
  delay(100); // Short delay for stability
}




-----------------------------------------------------------------------------------------------------------------------------Explanation of the Code

    • LDR Module Output Readingint ldrState = digitalRead(ldrPin); reads the state of the LDR module. The module will output LOW when it’s dark, and HIGH when it’s light.
    • LED Control:
      • If ldrState is LOW (dark), the LED is turned on.
      • If ldrState is HIGH (light), the LED is turned off.
    • Serial Monitor: Optional, but helpful for confirming the module’s state changes as lighting conditions vary.

    How the Project Works

    When the surrounding area becomes dark, the LDR module outputs LOW on the OUT pin, which the Arduino reads to turn on the LED. In bright conditions, the module outputs HIGH, and the Arduino turns off the LED, making it an automatic night light. This project is straightforward to adjust for different brightness levels by replacing the LDR module if necessary.

Circuit Simulation:

You can use Tinkercad to simulate this project. Let me know if you need more details or help setting up.

Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #wtc #Arduino #ideas #projects #diy #how #to #ArduinoProjects #UltrasonicSensor #HeightMeasurement #TechDIY #WeTechCreators

Post a Comment

0 Comments

Ad Code

Responsive Advertisement