Timers - Pycom WiPy 3.0 Manual

Hide thumbs Also See for WiPy 3.0:
Table of Contents

Advertisement

4.2.12 Timers

Timers
Detailed information about this class can be found in
Chronometer
The Chronometer can be used to measure how much time has elapsed in a block of code.
The following example uses a simple stopwatch.
from machine import Timer
import time
chrono = Timer.Chrono()
chrono.start()
time.sleep(1.25) # simulate the first lap took 1.25 seconds
lap = chrono.read() # read elapsed time without stopping
time.sleep(1.5)
chrono.stop()
total = chrono.read()
print()
print("\nthe racer took %f seconds to finish the race" % total)
print(" %f seconds in the first lap" % lap)
print(" %f seconds in the last lap" % (total - lap))
Alarm
The Alarm can be used to get interrupts at a specific interval. The following code executes a
callback every second for 10 seconds.
.
Timer
180

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the WiPy 3.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

SipyGpyLopyLopy4Fipy

Table of Contents