I have a loop that takes a three way switch input and selects an option on power up of a camera:
# Set GPIO input
switchColorOne = pyb.Pin("P9", pyb.Pin.IN, pyb.Pin.PULL_UP)
switchColorTwo = pyb.Pin("P7", pyb.Pin.IN, pyb.Pin.PULL_UP)
#Set color pallete by switch
if switchColorOne.value() == 0:
sensor.set_pixformat(sensor.RGB565)
elif switchColorTwo.value() == 0:
sensor.set_pixformat(sensor.GRAYSCALE)
else:
sensor.set_color_palette(sensor.PALETTE_IRONBOW)
sensor.set_pixformat(sensor.RGB565)
I would like to take the input from a single push button to cycle through the three options during the switch, preferably with a while loop so it can happen continually. I can't figure out how to make this happen, do I need a debouncer, can I use a for loop to iterate through different lines of code?