Time

Running Time

Running time is how long the program has been running in milliseconds

TIP: 1 second is 1,000 milliseconds

Elapsed Time:
    When Button Pressed
        set now to running time
        scroll now
  
\\where now is a user created variable

Time Stamps: the microbit has the ability to record the time using the advance: Time stamp button.

If we want to measure the elapsed time of between two events that occur while program is running we can use these time stamps and a little math.

on event1 (your choice)
    set time1 to event time stamp
    
on event2 (also your choice but diff than event1)
    set time2 to event time stamp
    
on start
    set duration = 0

after event 2 occurs and time2 stored
    duration= time2 - time1

Last updated