Skip to content
Snippets Groups Projects
Commit ac36e25b authored by ef1g21's avatar ef1g21
Browse files

Upload New File

parent 27329d3a
Branches
No related tags found
No related merge requests found
import machine
import utime
start = machine.Pin(20, machine.Pin.IN, machine.Pin.PULL_UP)
stop = machine.Pin(21, machine.Pin.IN, machine.Pin.PULL_UP)
buzzer_pin = machine.Pin(18, machine.Pin.OUT)
while True:
while start.value() == 1:
utime.sleep_ms(10)
startTime = utime.ticks_ms()
print("Start timer")
while stop.value() == 1:
utime.sleep_ms(10)
stopTime = utime.ticks_ms()
buzzer_pin.value(1)
utime.sleep(0.5)
buzzer_pin.value(0)
print("Timer stopped")
time = stopTime - startTime
timeInSecs = time / 1000
print("Stopwatch time:", timeInSecs, "s")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment