Skip to content

Atividade

Festive decoration

Iniciante | MakeCode | Sensor de luz, Som, Visor LED | Iteração, Sensores

Primeiro passo: o projeto

O que é?

Turn your micro:bit into a festive decoration that shows a flashing star on the LED display as soon as it gets dark.

Estes dois vídeos mostram o que você fará e como desenvolver o código:

Como funciona:

  • The program uses the micro:bit’s light sensor to measure the light levels.
  • It then uses an “if then else” logic block.
  • If the light levels are less than 100, the micro:bit is instructed to show two icons – a large star then a small star with pauses in between – in a forever loop on the LED display. This creates the animation.
  • A forever loop in a computer program is an instruction that repeats forever.
  • If the light levels are more than 100, the micro:bit is told to clear the screen.

Itens necessários:

  • Um micro:bit (ou simulador MakeCode);
  • Editor MakeCode;
  • battery pack (optional but recommended)
  • our set-up guide may be useful

Segundo passo: é hora de programar

Terceiro passo: vamos deixar o código ainda melhor

  • Adjust the threshold at which the animation plays to better suit your room.
  • Instruct your micro:bit to play a festive sound on pressing button A.
  • Make other festive projects such as a jukebox which plays festive tunes, or an alarm which comes on when Father Christmas arrives on Christmas Eve!