buttons
- Push Buttons¶
The buttons
module allows you to use card10’s push buttons as input
in your scripts.
Example:
import buttons
print("Press bottom left or right button:")
while True:
pressed = buttons.read(
buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT
)
if pressed != 0:
break
if pressed & buttons.BOTTOM_LEFT != 0:
print("Left button pressed!")
if pressed & buttons.BOTTOM_RIGHT != 0:
print("Right button pressed!")
Read button status.
- Parameters
mask (int) – Mask of buttons to check. Create the mask by ORing
buttons.BOTTOM_LEFT
,buttons.BOTTOM_RIGHT
,buttons.TOP_RIGHT
, andbuttons.TOP_LEFT
(=buttons.RESET
).- Returns
An integer with the bits for pressed buttons set. Use the same costants as for the mask to check which buttons were pressed.
Bottom left button.
Bottom right button.
Top right button.
Top left button (Reset button).
Top left button (Reset button).