cable Use one button for different outputs
Each time the button is pressed, a different output happens
touch_app music_note arrow_forward_ios arrow_forward_ios
touch_app music_note arrow_forward_ios music_note arrow_forward_ios music_note
bug_report Button not working
Do not add
() in
button.when_pressed = next_option
bug_report Button not working
Check your wiring. Also check if you have imported Button and set the pins.
option = 0 # Store the current option
# Call the next function and update the option
def next_option():
global option
if option == 0:
energised() # Your first option
elif option == 1:
calm() # Your second option
elif option == 2:
focused() # Your third option
# Move to the next option
if option == 2:
option = 0 # start from the beginning
else:
option = option + 1
button.when_pressed = next_option