LDR DEPENDENT LIGHTS

Aug 4, 2020
1 min read
Updated: Aug 6, 2022
This sunset to sunrise lighting switch is designed to control the light illuminated on the LDR sensor. The resistance of the LDR sensor changes with the change in intensity of light falling on LDR.
CIRCUIT DIAGRAM

CODE
#define led 11
int ldr = 0;
int bright = 0;
void setup()
{
pinMode(A4, INPUT);
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop()
{
ldr = analogRead(A4); //0-1023
Serial.println(ldr);
//bright = ldr/4 //0-255
bright = map(ldr,207,1012,0,255);
analogWrite(led,bright);
delay(10); // Delay a little bit to improve simulation performance
}


24/7 towing service in Brisbane for cars, containers, and equipment. Fast and cheap towing support for emergencies. Call for recovery help. Contact for cheap tow truck Brisbane, Australia. Visit: https://brisbanetowingandrecovery.com.au/
Our yoga school in Rishikesh is registered with the Yoga Alliance for its 200-hour Yoga TTC program. Our intensive Yoga TTC program, along with our mantra meditation course and online meditation course, is dedicated to imparting, guiding, and training students in a yogic way of life while learning to cultivate a harmonious lifestyle. Visit: https://www.ekattvayogshala.com/200-hrs-yoga-teacher-training-rishikesh