Passo 1: Faz tu mesmo
O que é isto?
Abana o teu micro:bit e recebe uma direção aleatória para onde começar a andar. Vais aprender sobre variáveis, números aleatórios e blocos de lógica de seleção e de comparação.
Estes dois vídeos mostram o que vais fazer e como programar:
Introdução
Guia do código
Como é que funciona
- The program uses a variable called “direction” to store a random number.
- Variables store numbers or values that can change in a computer program.
- Shake the micro:bit to set “direction” to a random number between one and three.
- The program then uses selection and comparison logic blocks to test the value of the variable.
- If “direction” is equal to 1, then an arrow pointing north shows on the micro:bit’s LED display. If “direction” is equal to 2, then the arrow points east. Otherwise, the arrow points west.
- To make the battery last longer, the program pauses for half a second after the arrow appears then clears the screen.
Do que é que precisas
- micro:bit (ou simulador MakeCode)
- Editor MakeCode
- battery pack (optional but recommended)
- our set-up guide may be useful
Passo 2: Cria o teu código
Passo 3: Melhora-o
- Add more directions.
- Use buttons to show icons for skipping, running, and jumping.
- Combine with the touch stopwatch program to make a motivational tool to use in sports lessons.
Thanks to David Hay, an educator in Alberta, Canada for sharing this brilliant project idea with us.