Micro:bit Bluetooth Challenge

- 2 mins

Can you build Scissor-Paper-Rock game using micro:bit and Bluetooth?

This post is the challenge for the Race Condition badge at Arctic IoT Challenge. The description for the badge is as follows:

At random, the jury will present a challenge. Timeboxed to one hour, the first team with a working solution gets all the points.

This time I am designing the challenge, so here it comes:

The Challenge

We want you to simulate a popular Scissor-Paper-Rock game using micro:bits. Each team gets two devices.

The Building Blocks

Connecting to a micro:bit

Connect the micro:bit to your computer using a micro USB cable. It should appear as a USB disk on your machine.

Editor and Language

Yan can use Python and the editor here: http://python.microbit.org/editor.html.

After you are done writing the code, click Download and you will get a binary file you will be using in the next step. Check out the help section for more information.

Python documentation for the API can be found here.

Deploying to a micro:bit

Copy the binary *.hex file from the previous step on to the micro:bit, just like you would copy to any USB drive.

Sending Data Between micro:bits

Now, over to connecting micro:bits and sending data over. Take a look at the example below. Make sure to change group=1 to a number between 0 and 255. Both chips should belong to the same group to connect to each other. You will be assigned a number.

from microbit import *
from radio import *
from random import*

#turn radio on and configure group
config(group=1, length=251)

while True:
    if button_a.was_pressed():
        #send the images
        send("Hello, World!")
    #receive data    
    data = receive()
    #check that we have received any data
    if data != None:
        #split the data into different pictures by the marker

        #clear the screen

The Scissor-Paper-Rock Game

Have a look at the simple implementation of the game. You will need to translate it to MicroPython and extend.

Pseudocode for the Scissor-Paper-Rock Game


[Spoiler alert!] The winning team gets to submit their code to this GitHub repo.

Rustam Mehmandarov

Rustam Mehmandarov

Passionate Computer Scientist

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora