Rock, Paper, Scissors for the BBC Micro:bit

  • First, head to http://jumpto.cc/pxt-new
  • You will now have the code editor ready to use, so let’s set an image for the start of the game. Drag a show leds box across into the start block.

Start image
Start image
  • We are going to shake the Micro:bit to tell it to choose between Rock, Paper and Scissors, so find and on shake block. Inside that we need to set a variable to a random number between 0 and 2 (remember variables from our Scratch projects).

  • Random number on shake
    Random number on shake
  • Depending on which number was chosen we want to show a different image. A 0 is going to be a Rock, so we need an if-then-else block. Look in the logic section to find a way to compare the variable (item) with 0, and then draw a picture of a Rock in a show leds block.

  • Is it a Rock?
    Is it a Rock?
  • We are still left with two more options, Paper or Scissors, so we need to have another if-then-else block in the else part of the block we’ve just added. This time we will check to see if item is 1 and draw a picture of a piece of Paper.

  • Is it Paper?
    Is it Paper?
  • There are only 3 options, so for our simple project we can assume that if it isn’t Rock or Paper then it must be Scissors (with bigger projects be careful about making assumptions!), so put a show leds block in with an image of some scissors.

  • It must be Scissors
    It must be Scissors
  • To finish off we need to wait for a while to see which item has been chosen and then reset the image to the one we used at the start – why do you think that is a good idea?

  • Wait and reset
    Wait and reset
  • Once you’ve tested your project try clicking on the Javascript {} button at the top. This is the same project, but showing the Javascript code behind the blocks.
  • By Mr Tansom

    I have been a governor at Morelands since February 2008, and at Purbrook Park since November 2012. Back when I was at primary school there were no computers in classrooms, but by secondary we had some Commodore PETs and later BBC Micros. I ran one of the Code Club pilots in Morelands in 2012 and hope that by doing this some of the kids will get the chance to experience the sort of fun I had with my ZX81 and Spectrum back in the 80s.

    Leave a Reply

    Your email address will not be published. Required fields are marked *