Files
Udacity_Nanodegree_Robotics…/button.py
T
2026-07-30 16:19:15 -04:00

15 lines
330 B
Python

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