Raspberry Pi - GPIO Basics with Python
You wrote this code to read a button press on GPIO pin 5:
GPIO.setup(5, GPIO.IN)
if GPIO.input(5) == 1:
print("Button pressed")
else:
print("Button not pressed")
But the output is random even when the button is not pressed. What is the likely problem?