relay controller test with other modual
Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>master
parent
5be3422a5a
commit
255481d7cf
14
main.py
14
main.py
|
@ -25,16 +25,20 @@ def error_print(message: str):
|
||||||
|
|
||||||
#relay
|
#relay
|
||||||
def relay_controller(pin: int, state: str):
|
def relay_controller(pin: int, state: str):
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setup(pin, GPIO.OUT)
|
||||||
if state == "True":
|
if state == "True":
|
||||||
relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False)
|
# relay = gpiozero.OutputDevice(pin, active_high=False, initial_value=False)
|
||||||
relay.on()
|
# relay.on()
|
||||||
|
GPIO.output(pin, GPIO.LOW)
|
||||||
debug_print("Set relay-pin "+str(pin)+" to state True")
|
debug_print("Set relay-pin "+str(pin)+" to state True")
|
||||||
elif state == "False":
|
elif state == "False":
|
||||||
relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False)
|
# relay = gpiozero.OutputDevice(pin, active_high=False, initial_value=False)
|
||||||
relay.off()
|
# relay.off()
|
||||||
|
GPIO.output(pin, GPIO.HIGH)
|
||||||
debug_print("Set relay-pin "+str(pin)+" to state False")
|
debug_print("Set relay-pin "+str(pin)+" to state False")
|
||||||
else:
|
else:
|
||||||
error_print("Unknown state for relay ("+state+")")
|
error_print("Unknown state ("+state+") for relay channel "+str(pin))
|
||||||
|
|
||||||
#ultrasonic
|
#ultrasonic
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue