Skip to content
Snippets Groups Projects
Verified Commit 0c11fbf3 authored by Anian Bühler's avatar Anian Bühler
Browse files

changed examples (payload = xy)

parent 79f47875
No related branches found
No related tags found
1 merge request!9update master from dev2
......@@ -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
}
......
......@@ -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
......
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment