Files
pybricks-api/examples/pup/hub_primehub/button_stop.py
T
2026-08-24 09:28:29 +02:00

16 lines
500 B
Python

from pybricks.hubs import PrimeHub
from pybricks.parameters import Button
# Initialize the hub.
hub = PrimeHub()
# Configure the stop button combination. Now, your program stops
# if you press the center and Bluetooth buttons simultaneously.
hub.system.set_stop_button((Button.CENTER, Button.BLUETOOTH))
# Now we can use the center button as a normal button.
while True:
# Play a sound if the center button is pressed.
if Button.CENTER in hub.buttons.pressed():
hub.speaker.beep()