int pot = A0;
int ldr = A2;    
int led = 2; 
int light, threshold;

void setup() {
  pinMode(led, OUTPUT);  
}

void loop() {
  threshold = analogRead(pot); 
  light = analogRead(ldr); 
  if (light<threshold){
    digitalWrite(led, HIGH);   
  }
  if (light>threshold+10){
    digitalWrite(led, LOW);   
  }
  delay(500);                  
}
