![](https://github.com/Electroversity/Electroverse/raw/main/Basics%202/12-LDR%20dependent%20Light%20bulb/ldr%20bulb.png)
Here we deal with the integration of a Photoresistor or a Light dependent resistor with a light bulb. We specify a particular range for the Bulb to glow and other range to be off.
We use an SPDT to control the high power application through low power signal electronics circuits.
Have Fun !
SPDT Configuration:
NO(Normally Open) | Coil Pin | Common Pin |
---|---|---|
NC(Normally Close) | Coil Pin | Common Pin |
int sensorValue = 0; //value of sensor has been initialised to be 0
int Bulb = 7;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(Bulb,OUTPUT);
}
void loop()
{
sensorValue = analogRead(A0); //reading from the sensor
Serial.println(sensorValue); //printing the sensor value
/*Determing the range of sensor to trigger the bulb to glow*/
if (sensorValue<800){
digitalWrite(Bulb,HIGH);
Serial.print("Light is On - ");
}
else if(sensorValue>800){
digitalWrite(Bulb,LOW);
Serial.print("Light is Off, It's Dark - ");
}
delay(100);
}