Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.45 KB

File metadata and controls

60 lines (46 loc) · 1.45 KB

LDR dependent Light Bulb

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

Components Required

  1. 1x LDR
  2. 1x SPDT relay
  3. 1x Light Bulb
  4. Jumper Wires
  5. Arduino UNO

CODE

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);
}