Here is my Python code:
import RPi.GPIO as gpio
import time
gpio.setmode(gpio.BCM)
gpio.setup(22, gpio.IN)
while True:
input_value = gpio.input(22)
if input_value == False:
print('Pressed')
while input_value == False:
input_value = gpio.input(22)
else:
print('Not pressed')
time.sleep(0.1)
gpio.cleanup()
But my output is consistantly
Pressed
Not pressed
Not pressed
Not pressed
Not pressed
Not pressed
Pressed
Not pressed
Not pressed
Not pressed
Not pressed
Not pressed
Pressed
Not pressed
etc, etc.. If I have a button plugged in (similar to this), the output is still the same. wiringPi readall
shows similar results. Why is this happening?