12. Case 10: Finger-guessing game

12.1. Purpose


  • Use the Smart Coding Kit to create a finger-guessing game

12.2. Material


  • 1 x smart coding kit

../../_images/smart_coding_kit_case_10_01.png

12.3. Software


MicroSoftmakecode

12.4. Programming


Step 1

  • Set both the variables “i” and “k” as 0 and show the on start icon

  • Set the wireless group

  • While pressing button A or/and B, set the variable “k” as the equivalent number and send it to show the icon accordingly

  • After receiving the data, save the data as variable “i”

    ../../_images/smart_coding_kit_case_10_02.png

Step 2

  • In the Forever block, judge the value of “i” and “k”, if they are not 0, it means both the players give a “fist”

  • The winner will be judged by the comparasion of “i” and “k”

  • Set both the varibles “i” and “k” as 0 and be prepared for the next round

../../_images/smart_coding_kit_case_10_03.png

12.5. Result


Choose to give a “fist” through button A or/and B, the results will be given accordingly, the winner has a smile face and the loser has a cry face on the micro:bit.

12.6. Exploration


12.7. FAQ


12.8. Relevant File