Devices & Components
Arduino Nano
LDR module
LDR Resistor
relay module
LDR Resistor
AC to DC Adapter
Hardware & Tools
Tape, Scotch
Wire clippers
tester
drill, screwdriver, soldering iron
Tape, Insulating
Wire Stripper & Cutter, 22-10 AWG / 0.64-2.6mm Capacity Single & Stranded Wires
Multimeter
Hammer
Plier, Long Nose
Hot glue gun (generic)
Soldering flux
Tape, Clear
Software & Tools
Arduino IDE
Project description
Code
ANLPUAM
cpp
This is the Code for Microcontroller Chip.
1//LDR sensor-based Automatic Night Light Project 2 3//LDR MODULE Connections 4//connect 5V from Arduino to one leg of LDR. 5//Connect another leg of LDR to a 10K resistor and further connect it to the analog pin A0 of Arduino. 6// Connect another end of the 10k resistor to the GND of Arduino and the circuit is Done. 7 8// updated code to fetch the data with time on serial monitor (dated 3 AUG 2022) 9 10void setup() { 11 Serial.begin(9600); 12 pinMode(13,OUTPUT); 13 pinMode(12,OUTPUT); 14} 15void loop() { 16 { 17 float sensorValue = analogRead(A0); 18 // Reads the analog input ranging from 0 to 1023 19 //Serial.println(sensorValue); 20 if(sensorValue<= 600) // 600 is ideal, more the value, LED will keep glowing in brighter exposure. 21 { 22 digitalWrite(13,HIGH); 23 digitalWrite(12,HIGH); 24 Serial.println("LED ON"); 25 delay(2000);//two-second delay of time between readings. 26 // add this delay to avoid fluctuating signals during the natural transitions from dark to light and vice-versa due to sunlight. 27 } 28 else 29 digitalWrite(13,LOW); 30 digitalWrite(12,LOW); 31 Serial.println("LED OFF"); //Serial Monitor Display is optional 32 delay(2000);//two-second delay of time between readings. 33 // a little delay here is advisable otherwise relay switch may damage non-LED AC bulbs with fluctuations during natural transitions from day to night due to sunlight. 34} 35delay(2000);// even more delay of 2 seconds is optional. 36}
Downloadable files
Automatic Night Light Project Using Arduino Microcontroller
The circuit diagram for ANLPUAM.
AUTOMATIC NIGHT LIGHT PROJECT USING ARDUINO MICROCONTROLLER.png

Comments
Only logged in users can leave comments