I'm pretty new to the Pi and to this forum so sorry if this is a silly question but here we go.
I've been trying out the GPIO pins on the Pi and with some help from other posts on this forum I managed to get some LED's going using python - all very cool stuff.
Then I tried to read input on a pin so I wired it up to a push button but I'm getting really erratic readings, regardless of which pin I use.
When the pin is not connected to anything, the reading comes back as False consistently, which is fine. But as soon as I plug in a wire (not connected to anything at the other end!) I get random readings of True and False.
Am I doing something wrong?
The python code I'm using is as follows:
Code: Select all
while True: print(str(GPIO.input(22))) time.sleep(0.2)