The Best DIY STEM Tutorials and Projects

Automatic Night Light +

OVERVIEW

In this project we will make Automatic Night Light using Arduino Uno and an LDR, we will detect night (darkness) using LDR and switch on an LED if there is darkness in the room.

You can follow this video and instructions below to make this Amazing Automatic Night Light Project

Video

Components Required

Here is a list of Components that we will need to make this Project.

Sr #Item NameQuantity
1Arduino Uno1
2Breadboard1
3Male to Male Jumper Wire4
4LED1
5Resistor 10k ohms1
6Resistor 220k ohms1
7Piezo Buzzer1

Wiring Diagram

Here is a Complete Wiring Diagram along with Instructions for this Project

Program / Code

Code is Explained in the Comments of the Code

// Automatic Night Light by --- AceLabs ---

//set pin numbers
//const won't change
const int ledPin = 3;   //the number of the LED pin
const int ldrPin = A0;  //the number of the LDR pin


void setup() {

  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  //initialize the LED pin as an output
  pinMode(ldrPin, INPUT);   //initialize the LDR pin as an input
}

void loop() {

  int ldrStatus = analogRead(ldrPin);   //read the status of the LDR value

  //check if the LDR status is <= 300
  //if it is, the LED is HIGH

   if (ldrStatus <=300) {

    digitalWrite(ledPin, HIGH);               //turn LED on
    Serial.println("LDR is DARK, LED is ON");
    
   }
  else {

    digitalWrite(ledPin, LOW);          //turn LED off
    Serial.println("---------------");
  }
}

Thank you so much for going through our tutorial, we hope it was easy to follow and you enjoyed it, please share your feedback and pictures of the project (if you have made it) in the comments below .!

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *