Micro:bitMakeCodeExplore Students only

Night light and sunrise alarm

Your Micro:bit can feel light with its own screen. Make bars that follow the light, a night light that switches on in the dark, and an alarm that rings once when the sun comes up. Nothing to wire.

Two Micro:bits: at night all lights on under a moon, in the morning a sun picture and a ringing alarm

See it in action

On screen: night falls, the Micro:bit shows a moon; the sun comes up, the alarm rings once and the sun picture shows
Night, then sunrise story 3, in the light lab
Hand on, hand off a real one, our first alarm in 2023

Story by story

4 stories. Each one is a step that works on its own, and the next one builds on it. Then the challenges: real problems to solve.

  1. 1
    See the lightlight level
  2. 2
    Light on in the darkif and else
  3. 3
    Wake up with the suna variable that remembers
  4. 4
    Set it for your roommeasure first

What you learn

1 Logical thinking4 Programming1 Electronics1 Systems thinking1 AI competence

Explore with the Micro:bit alone: its light sensor, if and else, and a variable that remembers

Logical thinking

  • An alarm that never stops: find why, then fix it with one variable from story 3

Programming

  • forever asks for the light again and again, so the bars follow your hand
  • if light level < 30: the lamp goes on; else it goes off from story 2
  • rang remembers that the alarm has rung, so it rings only once from story 3
  • Button A saves the light you want to wake up to, B shows it from story 4

Electronics

  • The Micro:bit feels light with its own screen: light level is 0 in the dark and 255 in bright light

Systems thinking

  • Cover it, uncover it, shine a torch: test that it does what you planned

AI competence

  • You choose when you want to wake up: you measure your own room from story 4

Parts you need

For all the stories together. The first story needs the fewest parts; a small note says from which story a part comes in.

Micro:bit V2 and a USB cable
Battery pack with ON/OFF switch (for your bedroom)

In the full project guide