#define LdrPin A0
#define RelayPin 2
int lumen = 0;
void setup() {
pinMode (LdrPin,INPUT);
pinMode (RelayPin, OUTPUT);
digitalWrite(RelayPin, LOW);
Serial.begin(9600);
}
void loop() {
lumen = analogRead(LdrPin);
if (lumen <= 511) {
digitalWrite(RelayPin, LOW);
} else if (lumen >= 512 ) {
digitalWrite(RelayPin, HIGH);
}
Serial.println(lumen);
}