Detecting when switch is closed - Raspberry Pi Forums
hi all,
i'm new pi , electricals/electonics @ hobby level.
want use pi detect when contact closed. when motor engaged, circuit closed , existing circuit has lightbulb connected comes indicate motors engaged. connect pi contact can notified through pi when motors engaged.
have tried setup pictured on right, not sure if right way go it.
have connected inputs pi correctly (i.e. pin , gnd)?
design meaningful/appropriate?
have tried connect pi pictured bcm_gpio23 , gnd , enabled internal pullup resistor. when motor closed (contact opened) high when motor opened (contact closed) randomly both high , low until motor closed , constant high again. behavious makes plan unreliable cannot tell if motor closed or opened randomly checking pin input value.
please advise i've done wrong , better way. thanks
i'm new pi , electricals/electonics @ hobby level.
want use pi detect when contact closed. when motor engaged, circuit closed , existing circuit has lightbulb connected comes indicate motors engaged. connect pi contact can notified through pi when motors engaged.
have tried setup pictured on right, not sure if right way go it.
have connected inputs pi correctly (i.e. pin , gnd)?
design meaningful/appropriate?
have tried connect pi pictured bcm_gpio23 , gnd , enabled internal pullup resistor. when motor closed (contact opened) high when motor opened (contact closed) randomly both high , low until motor closed , constant high again. behavious makes plan unreliable cannot tell if motor closed or opened randomly checking pin input value.
please advise i've done wrong , better way. thanks
i see no image
i'm not sure have done, if chucking if switch open/closed how did it
toggle switch used play/pause button (wire pin 11 switch more wire +3.3v pin)
not know powering motor , light bulb, assume not 120v ac stuff sound pi did not explode, unless used double poll switch 1 poll pi , 1 motor
i'm not sure have done, if chucking if switch open/closed how did it
toggle switch used play/pause button (wire pin 11 switch more wire +3.3v pin)
not know powering motor , light bulb, assume not 120v ac stuff sound pi did not explode, unless used double poll switch 1 poll pi , 1 motor
code: select all
#!/usr/bin/python subprocess import call import rpi.gpio gpio import time pin = 11 gpio.setmode(gpio.board) gpio.setup(pin, gpio.in, pull_up_down=gpio.pud_down) try: while true: val = gpio.input(pin) if val == 1: call(["mpc","play"]) else: call(["mpc","pause"]) while gpio.input(pin) == val: time.sleep(0.75) except keyboardinterrupt: gpio.cleanup()
raspberrypi
Comments
Post a Comment