The Best DIY STEM Tutorials and Projects
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 Name | Quantity |
---|---|---|
1 | Arduino Uno | 1 |
2 | Breadboard | 1 |
3 | Male to Male Jumper Wire | 4 |
4 | LED | 1 |
5 | Resistor 10k ohms | 1 |
6 | Resistor 220k ohms | 1 |
7 | Piezo Buzzer | 1 |
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
1 file(s) 0.53 KB
// 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 .!