LDR
An LDR (Light Dependent Resistor) is a type of sensor that changes its resistance based on the amount of light falling on it. It is also commonly referred to as a photoresistor.LDRs can be used in light-sensitive circuits to activate or deactivate devices based on ambient light conditions. For example, they can be employed in automatic streetlights that turn on at dusk and turn off at dawn.
LDR sensor positive point to Arduino 5V
LDR sensor negetive point to Arduino A3
1000k Resistors positive point to arduino A3
1000k Resistor negative point to Arduino Gnd
Bulb positive point to Arduino 12
Bulb negetive point to Arduino Gnd
//start coding
const int Bulb = 12;
int ADC_value;
void setup() {
pinMode(Bulb, OUTPUT);
Serial.begin(9600);
}
void loop() {
ADC_value = analogRead(A3);
Serial.println(ADC_value);
delay(1000);
if (analogRead(A3) > 100) {
digitalWrite(Bulb, HIGH);
}
else{
digitalWrite(Bulb, LOW);
}
}