Micro:bit Finger-guessing Game

micro:bit Finger-guessing Game

Hello, today I am going to build a finger-guessing game with the micro:bit. If we shake the micro:bit, the micro:bit displays the scissor, stone or cloth at random, then we can play it with our partners.

The GIF Image:


The working principle is very simple---detecting the vibration event from the micro:bit: while the micro:bit is shaken, a random number from 1~3 is generated. We can program the numbers coinciding with the graphics of 1 as stones; 2 as scissors and 3 as clothes. I’d like to describe them with the graphics below:


Blocks used:

· Shaking event: on shake

· Display LED show leds

· Numbers generated at random: pick random 0 to 10

· Judgement

·if then/else if then/else

· Varaibles

1. Go to MakeCode: (https://makecode.microbit.org/) and create a new project.

2. Choose the on shake block.

3. Create a new variable and name it as “hand”.

4. Set the value of “hand” as a random number from 1~3.

5. If hand = 1.

6. Display stone.

7. Click to add choices.

8. Display cloth.

9. Click to add another choices.

10. If hand = 2

11. Display scissor.

Completed code:

Link: https://makecode.microbit.org/_8cVeyoEU39XA

If you have any ideas or opinions, please feel free to contact us via services@elecfreaks.com.