//Controlling relay state based on ambient light levels using LDR(Light Dependent Resistor) sensor.
int sensorPin = A0;
int sensorValue = 0;
int thresholdValue = 700;
int relayPin = 8;
void setup(){
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
}
void loop(){
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
if(sensorValue > thresholdValue){
digitalWrite(relayPin, HIGH);
}else{
digitalWrite(relayPin, LOW);
}
delay(100);
}