Ambient light controlled light

light=analogRead(1);
if (light < 500){
digitalWrite(relay,HIGH);
} else {
digitalWrite(relay,LOW);
}