From 255481d7cf52d0ecf48dc17ecc97552e78d0e092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Thu, 14 Jul 2022 10:47:42 +0200 Subject: [PATCH] relay controller test with other modual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index c2f40ae..7c81bbf 100644 --- a/main.py +++ b/main.py @@ -25,16 +25,20 @@ def error_print(message: str): #relay def relay_controller(pin: int, state: str): + GPIO.setmode(GPIO.BCM) + GPIO.setup(pin, GPIO.OUT) if state == "True": - relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False) - relay.on() + # relay = gpiozero.OutputDevice(pin, active_high=False, initial_value=False) + # relay.on() + GPIO.output(pin, GPIO.LOW) debug_print("Set relay-pin "+str(pin)+" to state True") elif state == "False": - relay = gpiozero.OutputDevice(pin, active_high=True, initial_value=False) - relay.off() + # relay = gpiozero.OutputDevice(pin, active_high=False, initial_value=False) + # relay.off() + GPIO.output(pin, GPIO.HIGH) debug_print("Set relay-pin "+str(pin)+" to state False") else: - error_print("Unknown state for relay ("+state+")") + error_print("Unknown state ("+state+") for relay channel "+str(pin)) #ultrasonic