Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import machine
- import utime
- import urandom
- pressed = False
- led_verde = machine.Pin(15, machine.Pin.OUT)
- led_rojo = machine.Pin(11, machine.Pin.OUT)
- led_amarillo = machine.Pin(13, machine.Pin.OUT)
- button = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_DOWN)
- def button_handler(pin):
- global pressed
- if not pressed:
- pressed=True
- timer_reaction = utime.ticks_diff(utime.ticks_ms(), timer_start)
- print ("tu reacción fue " + str(timer_reaction) +
- " milliseconds!")
- led_verde.value(1)
- utime.sleep(urandom.uniform(5, 10))
- led_verde.value(0)
- timer_start = utime.ticks_ms()
- button.irq(trigger=machine.Pin.IRQ_RISING, handler=button_handler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement