Pull up circuit doesn't work? - Raspberry Pi Forums


hi! tried pull circuit instructions link https://www.raspberrypi.org/learning/ph ... l_up_down/.
code this:

code: select all

import time import rpi.gpio gpio gpio.setmode(gpio.bcm) gpio.setwarnings(false)  button = 4  gpio.setup(pin, gpio.in, gpio.pud_up)  while true:   button_state = gpio.input(button)   if button_state == gpio.high:     print ("high")   else:     print ("low")   time.sleep(0.5)
when try run gives error: "pin" not defined
have tried sudo idle3 still doesn't work.
can figure out what's problem? :)

you're assigning pin number variable called "button" using undefined variable called "pin". in line below change pin button , should set:

code: select all

gpio.setup(pin, gpio.in, gpio.pud_up) 


raspberrypi



Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code