First commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
from utime import sleep
|
||||
from machine import Pin
|
||||
|
||||
class Button:
|
||||
def __init__(self, pin):
|
||||
self.pin = Pin(pin, mode=Pin.IN, pull=Pin.PULL_UP)
|
||||
|
||||
def is_pressed(self):
|
||||
return self.pin.value() == 0
|
||||
|
||||
def wait_button_press(self):
|
||||
while self.is_pressed() == False:
|
||||
sleep(0.01)
|
||||
return
|
||||
Reference in New Issue
Block a user