From 88a71796a7ec2e5819f8767ba68e1324304fcbea Mon Sep 17 00:00:00 2001 From: Ghost <31184695+GHOSCHT@users.noreply.github.com> Date: Thu, 30 Jul 2020 21:00:02 +0200 Subject: [PATCH] Add on & off commands + Relay state communication --- Arduino/ArduinoRelayControl.ino | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Arduino/ArduinoRelayControl.ino b/Arduino/ArduinoRelayControl.ino index 30b9e01..1be29af 100644 --- a/Arduino/ArduinoRelayControl.ino +++ b/Arduino/ArduinoRelayControl.ino @@ -10,6 +10,7 @@ byte buttonState[relayCount]; byte lastButtonState[relayCount]; String receivedCom; +String sentStatus; void setup() { @@ -41,11 +42,25 @@ void loop() { receivedCom.replace(String(i), ""); relayState[i] = !relayState[i]; - Serial.println(i); + } + + if (receivedCom == "off") + { + relayState[i] = LOW; + } + + if (receivedCom == "on") + { + relayState[i] = HIGH; } digitalWrite(relayPin[i], relayState[i]); EEPROM.update(i, relayState[i]); lastButtonState[i] = buttonState[i]; + sentStatus += relayState[i]; } + + Serial.println(sentStatus); + sentStatus = ""; + receivedCom = ""; } \ No newline at end of file