Buttons

The StudioBot has two push buttons that can be used to collect user input.

The following example shows how to setup the robot to use the switches to detect user input.

import time
import board
from StudioBot import *

while True:
    
    if buttons.is_1_pressed():
        print("Switch 1 On")
    else:
        print("Switch 1 Off")
        
    if buttons.is_2_pressed():
        print("Switch 2 On")
    else:
        print("Switch 2 Off")

    time.sleep(0.01)  # debounce delay

Last updated