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!
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: 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
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);
hope helps
gerhard
raspberrypi
Comments
Post a Comment