Add on & off commands + Relay state communication

This commit is contained in:
GHOSCHT 2020-07-30 21:00:02 +02:00
parent a995a19211
commit 88a71796a7

View file

@ -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 = "";
}