I have recently bought a Raspberry Pi 3B, for a project where I require a program to recognize a pressed button and do something after that. It seems a common and pretty easy task for a Pi, however I am starting by creating minimal examples to get acquainted with GPIO and electrical stuff (I am a developer, not an electrical engineer).
Gathered from various examples across the internet I have done the following:
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.IN) while True: if not GPIO.input(11): print("Button pressed") time.sleep(0.2)
The resistor between blue and red is 10k Ohm, the one to the ground is 1k Ohm.
I start the program using
sudo python test.py
I use standard raspbian (freshly flashed, everything updated)
Can somebody see what I am doing wrong? The print statement is not issued if connect the green and red wire at the bottom manually.