I have it connected on the GND pin to GPIO pin 11 (BCM 17) and a 1 kohm resistor to GND on the Raspberry Pi, the 3.3 V pin from the Raspberry Pi to positive:
Switch '+' -> 3.3 V Switch '-' -> GPIO ALSO to resistor and then GND of the Raspberry Pi.
I have this code:
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN) while True: if(GPIO.input(11) == True): print("switch ON") else: print("switch OFF")
But it only ever says that it's off. Why is this?