Micro:bit & Rock Paper Scissors

Micro:bit & Rock Paper Scissors

Rock Paper Scissors, you might know it well for you had played it in your childhood again and again. No matter how fairness it seems, this game has drawback, which comes from your hand motion speed and tricks,and you must have observed if you paid attention to it. We all know that BBC micro:bit has Bluetooth function and different micro:bit boards can transmit data with it. Today we are going to use this Bluetooth function to play Rock Paper Scissors. Bluetooth signal is unseen and untouchable so that it will completely eradicate tricks during the game.

Our Goal:

Through studying the case i am going to show you, you can gradually get to know the usage of micro:bit Bluetooth function such as Group ID setting, data transmission and data receive.

Our Requirement:

    1. Press button "A" to choose Rock, Scissors or Paper.
    2. Press button "B" to confirm our choice and transmit it with Bluetooth.
    3. If we have finished choose and received data transmitted from our partners, then micro:bit will begin to judge who wins and display it on the panel.

Materials Needed:

Micro:bit ×2

USB Cable ×2


Step 1: Set different Bluetooth group ID. Here we set group ID to be 13. Only if two micro:bit board have same group ID, then Bluetooth communication can be done. We use button "B" to confirm. Set button to "0", means we do not press button while set to "1" means button pressed down. We set variable " received" to show it has received Bluetooth signal. "0" for not-received and "1" for received. We use variable "item" to preserve our hand signs. "0" for rock, "1" for scissors, and "2" for paper.

Step 2: Set the function of button "A". Every press changes pattern order. We use pattern

to show rock, pattern

to show scissors, and pattern

for paper.

Step3: Set the function of button "B". With Bluetooth signal, we can send out our hand signs(i.e. variable "item") At the same time, set button to "1".

Step 4: Set Bluetooth receiving function. Store the received data into variable "receiveNumber", and set"received" to "1".

Step 5: Judge in "while" circulation. Once we showed our choice, then it will start to judge who wins. Usually we use

to show victory,

for lose, and

for tie.

Then, let's download the code into micro:bit and see what will happen.


If we want to show rock, scissors, or paper randomly, then how shall we change our program? For more interesting postings, you can follow up our blog or leave your comments.

Relative Readings:

ElecFreaks Micro:bit Adapter