Page 59 - RoboGenius Pro C5
P. 59

Your block-based code will look like this.























                  STEP - 20   Click on the Shake button to run the program.

                               You  can also download  the code  to  your  Micro:bit  by  clicking  the
                               Download  button  in MakeCode  then connect  the Micro:bit  to  your

                               computer and transfer the file.

                 Output

                 When the program runs, shaking the Micro:bit activates its accelerometer
                 sensor, which detects the motion and triggers the code.

                 The Micro:bit then generates a random number, 0, 1 or 2, to decide whether to

                 display rock, paper or scissors.

                    n If the random number is 0, the Micro:bit displays a
                    rock icon on its LED display, represented by a small

                    square.






                                                     n  If the random number is 1, it displays a paper icon on
                                                     its LED display, represented by a large square.








                    n If the random number is 2, it displays a scissors icon
                    on its LED display, shown as a scissors shape on the

                    LED display.




                                                                             Creative Projects with Micro:Bit
                                                                                                                    57
   54   55   56   57   58   59   60   61   62   63   64