I have a toggle button with 3 pins. I want to use it to turn 2 leds, when it's in one position turn on one led (red) and when it's in the other position turn on the other led (green).
I found a lot of information about push buttons, but no about toggle buttons. I tried it using the 5V GPIO like in the schematic below.
Now I want to use 2 GPIOs as inputs to know what led is receiving the current. I'm sure it's possible, i'm sure it's easy but i'm a noob.
My idea is do this:
GPIO.setup(20, GPIO.IN) GPIO.setup(21, GPIO.IN) green_led_state = GPIO.input(20) red_led_state = GPIO.input(21) if green_led_state == True and red_led_state == False: print('Green led active') if red_led_state == True and green_led_state == True: print('Red led active')