Getting a button to control code - Raspberry Pi Forums


first of all, have raspberry pi model 2 running raspbian. want connect button (in case adafruit 30mm arcade button).

i've based connections , code best of abilities using this adafruit tutorial can't python code react button press.

connections pictured in attachment. script below.

when run script (as sudo), doesn't thing.

appreciated!

code: select all

from time import sleep import rpi.gpio gpio gpio.setmode(gpio.board) gpio.setup(40, gpio.in)  while true:     if (gpio.input(40) == true):         print("pressed")     sleep(0.1);

hello,
meaning of 'doesnt thing' ? no error message, no printouts ?

place printout gpio-value loop:

code: select all

from time import sleep import rpi.gpio gpio gpio.setmode(gpio.board) gpio.setup(40, gpio.in)  while true:     print( gpio.input(40) )     if (gpio.input(40) == true):         print("pressed")     sleep(0.1);
not clear picture whether have pullup or pulldown hardware setup. if yellow 3.3, white gnd, should expect 'low' or '0' when pressed. other way round '1'.

hope helps
gerhard


raspberrypi



Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support