https://toitlang.org/ logo
The way you implement this in Toit is to block on ...
# general
f
The way you implement this in Toit is to block on the change:
pin.wait-for 1
Under the hood, Toit uses interrupts to wake up your task, when the pin changes. If you want to do other things while waiting you just do this
wait-for
in a separate task.
Copy code
task::
  while true:
    pin.wait-for 1
    print "1"
    pin.wait-for 0
...
Note that you would usually have a small sleep before/after each
wait-for
to debounce