"It’s Here! The BFCM Sale of the Year – Grab Your Favorites!"

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:

Principle:

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:

Program

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 [email protected].

Leave a Reply

images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
images
Children’s Programming Education is the Future Trend
images
Technical verification! Nezha series products can complete WRO competition tasks
images
Let's take part in the Ceremony of the New Factory of ELECFREAKS together!
images
Bluetooth Bee(HC-05 and HC-06) User Guide
images
In March, ELECFREAKS supported 5 schools to carry out school science and technology festival activities
Monthly Archive