Create the following circuit:

Enter the following code (note that you may need to adjust the threshold value, depending on your room's ambient lighting):
// Pins
const int light_pin = A0;
const int led_pin = 6;
// Set darkness threshold
const int threshold = 900;
void setup() {
pinMode(led_pin, OUTPUT);
}
void loop() {
// Read light value
int val = analogRead(light_pin);
// Turn LED on if light value is below threshold
if ( val < threshold ) {
digitalWrite(led_pin, HIGH);
} else {
digitalWrite(led_pin, LOW);
}
}
Simulator: https://tinkercad.com/things/cHGrr0pl7Zp