Page 73 - Ai Robogenius
P. 73

STEP - 10   Drag the show number block and place it below                   on  shake

                               the change steps by 1 block.
                                                                                                change steps  by  1
                  STEP - 11   Drag  the  steps  variable from the  Variables                    show number steps
                               category  and place  it  inside  the  show  number

                               block.

                               This will display the total number of steps counted on the LED display.


                               Your block-based code will look like this.


























                  STEP - 12   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, the Micro:bit starts counting steps using its accelerometer
                 sensor. Each time  you  shake  or move  the  Micro:bit,  the  accelerometer  detects

                 the motion and increases the step count by one. The total number of steps is then
                 displayed on the LED display using numbers.




















                                                                             Creative Projects with Micro:Bit
                                                                                                                    71
   68   69   70   71   72   73   74   75   76   77   78