diff --git a/examples/sPSN_Client1/sPSN_Client1.ino b/examples/sPSN_Client1/sPSN_Client1.ino index 2ba99f19df3c8532ff95da902fee8b9a4672e480..5230231c626056447068c1acf52db73e9bccf36a 100644 --- a/examples/sPSN_Client1/sPSN_Client1.ino +++ b/examples/sPSN_Client1/sPSN_Client1.ino @@ -49,7 +49,7 @@ void newData(char* topic, char* payload) { boolean static stateLED = false; //Wechsle Zustand der Variable "stateLED" wenn Taster beim Sender gedrueckt wurde - if(bool(atoi(payload)) == true){ + if(payload[0] == '1'){ stateLED = !stateLED; digitalWrite(LED_PIN, stateLED); //Setze Ausgang entsprechend dem empfangenen Wert } diff --git a/examples/sPSN_Client2/sPSN_Client2.ino b/examples/sPSN_Client2/sPSN_Client2.ino index 61581fec61b31b41b1507c694c70783243dfa831..d7cde74b8cda0b5f75dbb95dc84dbbd15e19bf6b 100644 --- a/examples/sPSN_Client2/sPSN_Client2.ino +++ b/examples/sPSN_Client2/sPSN_Client2.ino @@ -44,7 +44,8 @@ void newData(char* topic, char* payload) { int valuePoti = atoi(payload); //wandle ASCII-Zeichen in Wert //Alternativ: sscanf(mData, "%d", &stateLED); //wandle ASCII-Zeichen in Wert - int valueLED = constrain(map(valuePoti, 0, 1023, 0, 255), 0, 255); //passe analogRead-Wert (0-1023) für analogWrite (0-255) an und begrenze + int mappedValue = map(valuePoti, 0, 1023, 0, 255); + int valueLED = constrain(mappedValue, 0, 255); //passe analogRead-Wert (0-1023) für analogWrite (0-255) an und begrenze analogWrite(LED_PIN, valueLED); //Setze Ausgang entsprechend dem empfangenen Wert analogWrite(LED2_PIN, 255-valueLED); //Setze Ausgang invertiert zum empfangenen Wert diff --git a/examples/sPSN_PlotTopics/sPSN_PlotTopics.ino b/examples/sPSN_PlotTopics/sPSN_PlotTopics.ino index 1a6f3957ec695b7d3d8ee2bb19250936bd58460a..c39af3423a9eb0d353a65981eed4162dd9adeaf3 100644 --- a/examples/sPSN_PlotTopics/sPSN_PlotTopics.ino +++ b/examples/sPSN_PlotTopics/sPSN_PlotTopics.ino @@ -23,8 +23,7 @@ DidacticPSNetClient psnClient; //Erzeuge PubSub-Client-Instanz //Callback-Funktion - in diesem Beispiel nicht verwendet -void newData(char* topic, char* payload) { -} +void newData(char* topic, char* payload) {} void setup() {