Page 153 - KEC Khaitan C5 Flipbook
P. 153

Pin Events: Detect when specific pins on the Micro:bit are touched or released.













                   Radio Events: Allow communication between Micro:bits using the radio feature.



























                 CUSTOMISING EVENTS FOR STEP TRACKING

                 To improve accuracy, instead of using the shake gesture, you can use the acceleration
                 function with threshold values to detect steps more reliably. By setting custom parameters,
                 we ensure that the step counter reacts only to valid walking movements.

                 Step  1  Click on Basic, then forever to create a continuous loop.

                 Step  2  Click on Logic, drag an if block inside forever.
                 Step  3   Click on Input, select acceleration (Strength), and set a threshold value (e.g., <
                         1500).

                 Step  4  Click on Variables, drag change stepCount by 1 inside the if block.

                 Step  5  Click on Basic, drag show number block, and place stepCount inside it.

                     basic.forever(function () {

                          if (input.acceleration(Dimension.
                           Strength) < 1500) {
                             stepCount += 1

                             basic.showNumber(stepCount)

                         }
                     })


                                                                                              Maker with Micro:bit  151
   148   149   150   151   152   153   154   155   156   157   158