How to Create Step Counter on micro:bit

Updated: Mar 4

Following are the steps for creating step counter


  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 step counter then this window will display


4. To build a counter, we'll need a variable step to store the number of steps




5. from variable drag and drop set step block set as 1 and place into on start block



6. we can use the on shake event to detect a step (it should notice a step most of the time)


7. let's add the code to increment step by 1 when the micro:bit is shaken



8. we want to always see how many steps were counted. in a forever loop, we add a show number block to display the value.



9. to display of step to avoid lag or delay in displaying , add stop animation after changing the value of the step.




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


11. The result is shown below: it will count the step when we shake the micro:bit


Result:


//video

17 views0 comments

Recent Posts

See All