Skip to content


Get up!

초급 | MakeCode, Python | LED, 빛 센서, 사운드 | 반복 실행, 선택 실행, 센서, 수 & 위치 값

1단계: 만들어 보세요.

프로젝트 소개

Turn your micro:bit into a light-sensitive alarm to help you get up in the morning. You'll learn how to use infinite loops, and selection with comparison logic.

다음 동영상을 통해 만들고 프로그래밍하는 방법을 살펴보세요.:


  • The program uses the micro:bit’s LED display as a light sensor.
  • Selection ('if... else') and comparison logic (> 70) are used so that if the light level is above a certain amount, a sun icon appears and it makes a noise; else, it clears the screen.
  • If the light level is greater than (>) 70, a sun appears on the LED display, telling you it’s time to get up.
  • The program uses an infinite loop to keep sensing the light level.
  • You can adjust the threshold at which the sun appears. Use larger numbers to make it less sensitive to light, so the alarm only goes off when it's brighter - or smaller numbers to make it more sensitive to light.


  • micro:bit (or use the simulator in the online editors)
  • MakeCode 또는 Python 편집기
  • 배터리 팩(선택 사항, 있으면 좋음)

2단계: 프로그래밍 해보세요.

1from microbit import *
2import music
4while True:
5    if display.read_light_level() > 70:
7        "90909:"
8        "09990:"
9        "99999:"
10        "09990:"
11        "90909"))
13    else:
14        display.clear()

3단계: 더 좋게 만들어 보세요.

  • Change the alarm sound.
  • Replace the sun icon with motivational messages that can help you to start your day.