int LDRPin = A0;
int LEDPin = 2;
void setup() {
// put your setup code here, to run once:
pinMode(LDRPin, INPUT);
pinMode(LEDPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int LDRPinValue = analogRead(LDRPin);
if (LDRPinValue < 500) {
digitalWrite(LEDPin, HIGH);
} else {
digitalWrite(LEDPin, LOW);
}
delay(1000);
}