πŸŒ™

Automatic Night Light

Explorer Β· Ages 7–9

  1. 1Read the conceptLearn the big idea behind this project.
  2. 2Check the partsSee which parts the robot needs.
  3. 3Follow the build stepsBuild it step by step, then test it.
  4. 4Answer the quizTap one answer for each of the 10 questions to earn XP.

πŸ’‘ The concept

A light sensor (LDR) measures how bright the room is. When it gets dark, the microcontroller reads a low light value and switches an LED on. When it is bright again, the LED turns off. This is the Sense β†’ Think β†’ Act idea in its simplest form.

Parts you need

  • Light sensor (LDR)
  • LED
  • Resistor
  • Microcontroller
  • Battery

πŸ”Ž Parts specification

Exactly what each part is, which models to buy, and what it does.

Microcontrollerβ–Έ

Suggested models: BBC micro:bit V2, Arduino Uno R3, or Raspberry Pi Pico

Features: The brain of the project. Reads the sensor on an analog input pin, decides with your code, and switches the LED on a digital output pin. The micro:bit is easiest for beginners (built-in LEDs and buttons); the Arduino Uno is the classic school board.

Light sensor (LDR)β–Έ

Suggested models: GL5516 / GL5528 photoresistor

Features: A resistor that changes with light: low resistance when bright, high resistance when dark. Cheap, no polarity, and reads as an analog value (0–1023) when paired with a fixed resistor in a voltage divider.

LEDβ–Έ

Suggested models: Standard 5mm LED, any color

Features: The light output. Long leg is + (anode), short leg is βˆ’ (cathode). Needs about 2V and 20mA β€” always use it with a resistor.

Resistorβ–Έ

Suggested models: 220Ξ© (for the LED) + 10kΞ© (for the LDR divider)

Features: The 220Ξ© protects the LED from too much current. The 10kΞ© pairs with the LDR so the sensor gives a readable voltage.

Battery / powerβ–Έ

Suggested models: 2Γ—AA battery pack, USB cable, or 9V with clip

Features: Powers the board. 3V–5V is plenty. Never connect power while building the circuit.

πŸ’» Program the microcontroller

πŸ“² App to use: Microsoft MakeCode (makecode.microbit.org) for micro:bit, or Arduino IDE for Arduino Uno

MakeCode is free, runs in the browser, and lets you drag blocks or type Python/JavaScript. Arduino IDE is a free download and uses C++.

// Arduino IDE (C++) β€” Automatic Night Light
const int sensorPin = A0;  // LDR voltage divider
const int ledPin = 9;      // LED with 220Ξ© resistor
const int DARK = 400;      // tune this number!

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

void loop() {
  int light = analogRead(sensorPin);
  if (light < DARK) {        // room is dark
    digitalWrite(ledPin, HIGH);  // LED on
  } else {
    digitalWrite(ledPin, LOW);   // LED off
  }
  delay(100);
}

🧠 How it works: The loop reads the light level 10 times a second. When the value drops below DARK (400), the LED turns on. Cover the sensor to test, then raise or lower DARK until it switches at the right moment. In MakeCode the same logic is: forever β†’ if analog read < 400 β†’ digital write 1, else 0.

πŸ› οΈ Build it step by step

Press Play to watch every part go into place and every wire connect. Ask a grown-up to help with real wiring!

+ βˆ’BatteryMicrocontroller

Step 1 of 6

πŸ”‹ Power the board

Connect the battery to the microcontroller's power pins (red wire to +, black wire to βˆ’). Keep the battery switched OFF while you build.

🧠 Project quiz

Question 1/10⭐ 0

What does a light sensor measure?