03micro:bit ยท MakeCode 25 minutes
Shake-to-roll dice
Use the motion sensor to roll a random number from 1 to 6.

Lesson goal: Use the shake gesture and randint(1, 6) to make an electronic dice.
Open MakeCodeSection 1
Understand
- accelerometer
- gesture event
- random number
- inclusive range
- 1The accelerometer senses motion.
- 2On shake, pick a random number from 1 to 6.
- 3Show it on the display.
Safety first
- Shake gently over a table or soft surface, holding the cable so the board cannot fly off. Do not throw the board.