Skip to main content

Buttons

Buttons

Library

Stemi provides four already initialized buttons to user code. They can be accessed through the global variable buttons. They correspond to properties A, B, C and D of variable buttons.

button.py
class Button:
def __init__(self, pin):
...

def read(self):
...

def read_int(self):
...

Explanations

ReturnsDescription
__init__a Button instancecreates an instance of the button class and sets it up
readbooleanreturns True if the button is pressed, False otherwise
read_intintreturns 1 if the button is pressed, 0 otherwise

Example

main.py
print(buttons.A.read())
print(buttons.B.read_int())
print(buttons.C.read())
print(buttons.D.read_int())
note

buttons is a global variable that you'll be provided with