How to Create Stopwatch on micro:bit

Updated: Mar 4

Following are steps for creating Stopwatch

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


4. First remove on start block and forever block from editor workplace then from input drag and drop on button A pressed on editor workplace


5. Create a variable start and put set start block on button A pressed to running time (ms)

 
 

6. Create a variable elapsed and put it in the set elapsed block on button B pressed to running time (ms) to start. (That means ad code to compute the difference between the running time and value time. this is the elapsed millisecond since pressing button A)



7. Add code to show the number of milliseconds elapsed. use integer division to divide elapsed by 1000 and get seconds



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


9. Result : Press A to start the stopwatch and press B to get the current elapsed time. you can press B multiple time


Result:

//video


26 views0 comments

Recent Posts

See All