const int LDR = 0; const int led = 8; int lightCal; int lightVal; void setup() { // We'll set up the LED pin to be an output. pinMode(led, OUTPUT); lightCal = analogRead(LDR); } void loop() { lightVal = analogRead(LDR); if (lightVal < lightCal - 50) { digitalWrite(8, HIGH); } else { digitalWrite(8, LOW); } }