Mini "Guess the Number" Game Machine With Micro:bit

Introduction: Mini "Guess the Number" Game Machine With Micro:bit

Have you ever played "Guess the Number"? This is a very easy-to-build mini game machine that plays "Guess the Number" with you. We designed this DIY project to encourage physical play and help kids learn programming. It uses a MU Vision sensor to sense the number cards, through which the player will try to guess the random number that the machine has chosen.

The setup is all explained in this picture.

A MU vision sensor that can recognize printed number cards is connected to the Micro:bit via I2C bus. The two PCB boards and a speaker are held together using a stand built from LEGO technic pieces so that the camera is looking down at a 45 degree angle. Make sure there is nothing to block the camera view to the front of the Micro:bit where the player will present the number card to the machine.


BBC micro:bit board ×1

Morpx MU Vision Sensor III ×1

LEGO Technic Pieces ×1 Pimoroni pin:bit ×1

Speaker: 0.25W, 8 ohms

Step 1: Connecting the Wires

You will need to connect 6 wires. The speaker has two wires connecting to the "0" and "GND" pin of Micro:bit. The MU Vision sensor has 4 wires connecting to the I2C bus -- 3V, pin 19 (SCL), pin 20 (SDA)and GND.
In the picture, we just solder the wires to the Micro:bit contact pad. You can also use one of the breakout board for micro:bit to connect the wires.

Step 2: The MU Vision Sensor III

The MU Vision sensor is the main AI module that recognizes different number cards. It has I2C output port that can be used to connect to the Micro:bit (pin 19 and pin 20).

1. To connect to Micro:bit, the vision sensor's left DIP switch 2 need to set to "ON" to use the I2C mode.

2. The vision sensor is mounted upside down (the sensor connector facing toward player) so that when the player present the number card to the machine it is "frontal" from the player's point-of-view.

Step 3: Programming Micro:bit Via Makecode

You can program the machine using MakeCode. You can program the Micro:bit in both Javascript or in block code. To make it simple we use block programming to illustrate here.
1. Import the MUVisionSensorIII library By selecting "Advanced" -> "Extensions", and type "mu-opensource/MuVisionSensorIII-MakeCode" in the search box. Select the "Muvs" extension from the result.

You will now find the MuVisionSensor blocks like this

Step 4: Initialize MU Vision Sensor

2. Initialization of MU Vision Sensor in the on start block and set it to use I2C bus.

and Add Number Card algorithm.

Step 5: Add Code to Process the Detection Result

In the Forever loop, add code to process the detection result from MU Vision Sensor.

Step 6: Display the Result on the LED Matrix

We use a custom function to display the number recognition result.
Note: Since we placed the Micro:bit vertically, the number on the LED display need to be rotated by 90 degree.

Step 7: Game Logic

You can program micro:bit to give out a little hint for the secret number.

Step 8: Add Life Bar

You can also life to the game for a bit more fun. We use the left column of the LED matrix to display the "life bar"

Step 9: Add Music

That's it. Due to the space reason, not all code are shown in the figure above. You can find the full code here.

Step 10: Summary

This tutorial teaches you how to build a mini game machine using Micro:bit and the MU Vision Sensor. With the help of visual recognition from the MU Vision Sensor, you can build many similar "physical play" games on the Micro:bit platform.

Be the First to Share


    • Mason Jar Speed Challenge

      Mason Jar Speed Challenge
    • Bikes Challenge

      Bikes Challenge
    • Remix Contest

      Remix Contest