Arduino bleibt bei MQTT Callback stecken. Wie bekomme ich es hin, dass ich nach der Auswahl von z.B. Effekt 0 auf Effekt 1 wechseln kann? Momentan ist es so wenn ich zu Effekt 1 oder 0 wechsle, kann ich dem Arduino keine weiteren Befehle geben oder den Effekt stoppen.
Vielen Dank im Vorraus
void MQTTcallback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived in topic: ");
Serial.println(topic);
Serial.print("Message:");
String message;
for (int x = 0; x < length; x++) {
message = message + (char)payload[x]; //Convert *byte to String
}
Serial.print(message);
if (strcmp(topic,"/ESP8266TEST/Interface/test/led")==0){
if(message == "1") {digitalWrite(LED_BUILTIN, LOW); Serial.print(" = LOW");} //LED on
if(message == "0") {digitalWrite(LED_BUILTIN, HIGH); Serial.print(" = HIGH");} //LED off
}
if (strcmp(topic,"/ESP8266TEST/Interface/test/effects")==0){
while(message == "0") {
Serial.println(F("Count0"));
// Part 1 EINZELN
for (int i = 0; i <= 8; i++) {
leds[i] = CRGB ( 0, 0, 255);
FastLED.show();
delay(30);
}
for (int i = 8; i >= 0; i--) {
leds[i] = CRGB ( 255, 0, 0);
FastLED.show();
delay(30);
}
for (int i = 0; i <= 8; i++) {
leds[i] = CRGB ( 0, 255, 0);
FastLED.show();
delay(30);
}
}
while(message == "1") {
fill_solid(leds, NUM_LEDS, CRGB(255,0,0));
FastLED.show();
delay(500);
fill_solid(leds, NUM_LEDS, CRGB(0,255,0));
FastLED.show();
delay(500);
fill_solid(leds, NUM_LEDS, CRGB(0,0,255));
FastLED.show();
delay(500);
fill_solid(leds, NUM_LEDS, CRGB(255,255,0));
FastLED.show();
delay(500);
}
}
if(message == "2") {digitalWrite(LED_BUILTIN, HIGH); Serial.print(" = HIGH");} //LED off
if(message == "3") {digitalWrite(LED_BUILTIN, HIGH); Serial.print(" = HIGH");} //LED off
if (strcmp(topic,"/ESP8266TEST/Interface/test/color/red")==0){
payload[length] = '\0';
String colors = String((char *)payload);
// Extract R from the string
r = colors.substring(0, 3).toInt();
Serial.println(F(""));
fill_solid(leds, NUM_LEDS, CRGB(r,g,b));
Serial.println(r);
FastLED.show();
}
if (strcmp(topic,"/ESP8266TEST/Interface/test/color/green")==0){
payload[length] = '\0';
String colors = String((char *)payload);
// Extract G from the string;
g = colors.substring(0, 3).toInt();
Serial.println(F(""));
fill_solid(leds, NUM_LEDS, CRGB(r,g,b));
Serial.println(g);
FastLED.show();
}
if (strcmp(topic,"/ESP8266TEST/Interface/test/color/blue")==0){
payload[length] = '\0';
String colors = String((char *)payload);
// Extract B from the string;
b = colors.substring(0, 3).toInt();
Serial.println(F(""));
fill_solid(leds, NUM_LEDS, CRGB(r,g,b));
Serial.println(b);
FastLED.show();
}
Serial.println();
Serial.println("-----------------------");
}
Ganzer code:
https://hastebin.com/axavehipaw.cpp
[/code]
.