How to Create Rock Paper Scissor Game on micro:bit

Updated: Mar 4

Following are the Steps for creating Rock Paper Scissor Game

  1. Click this link https://microbit.org/

  2. Then click on official code editor Microsoft Make Code to do programming

  3. Then click on New Project and give project name as Rock Paper Scissor Game then this window will display


4. First remove on start and forever block from editor workplace then from input drag and drop on shake block to run code when you shake the micro:bit


5. Click on variables and make a variable named hand and place the set hand to block in the shake event


 
 

6. Add a pick random block from math to pick a random number from 1 to 3 and store it in the variable name hand



7. place an if block under the pick random and check weather hand is equal to 1. Add a show leds block that show a picture of paper. The number 1 will mean paper



8. Click the (+) button to add an else section and add a show leds block inside the else and then draw a picture of scissor in the leds



9. Click the (+) button again to add an else if section. Now add a conditional block for hand =2 to the condition in else if. since hand can only be 1,2,or 3 your code is covering all possible cases!


10. Get one more show leds block and put it in the else if. Make a picture of a rock in the leds




9. if you have a micro:bit connected into a laptop/ pc/ mobile using USB then , Click on download button and transfer your code ( hex file) to the micro:bit and see the result.


10. Your game is ready! Gather your friends and Just shake micro:bit and play rock paper scissors!


Result:


13 views0 comments

Recent Posts

See All