timer#
The timer attribute can also be called without brain as its own Class.
time()#
The brain.timer.time(units) method returns the elapsed time.
Parameters  | 
Description  | 
|---|---|
  | 
Optional. A valid   | 
Returns: The elapsed time in the specified unit.
clear()#
The brain.timer.clear() method resets the timer value to 0.
Returns: None.
reset()#
The brain.timer.reset() method resets the timer value.
Returns: None.
system()#
The brain.timer.system() method returns the system time.
Returns: The system time in milliseconds.
system_high_res()#
The brain.timer.system_high_res() method returns the high-resolution system time.
Returns: The high-resolution system time in milliseconds.
event()#
The brain.timer.event(callback, delay, arg) method registers a callback function for a timer event.
Parameters  | 
Description  | 
|---|---|
  | 
The callback function to be called when the event occurs.  | 
  | 
The delay before the callback function is called.  | 
  | 
Optional. The arguments to pass to the callback function.  | 
Returns: None.
# Define a function timer_event
def timer_event():
    # The Brain will print that timer has expired on the
    # Brain's screen.
    brain.screen.print('timer has expired ')
# Initialize a Timer object.
t1 = Timer()
# Run timer_event after 1000 milliseconds of delay.
t1.event(timer_event, 1000, ('Hello',))