I was wondering the best way to go about interrupting a loop with a button push.. heres my code. It's towards the bottom... right now its not working. thanks in advance.
- void processSlackMessage(String receivedpayload){
- DynamicJsonDocument doc(1024);
- deserializeJson(doc, receivedpayload);
- DeserializationError error = deserializeJson(doc, receivedpayload);
- if (error) {
- Serial.print(F("deserializeJson() failed with code "));
- Serial.println(error.c_str());
- return;
- }
- JsonObject obj = doc.as<JsonObject>();
- String type_msg = obj["type"];
- String texto = obj["text"];
- String channel = obj["channel"];
- if(type_msg.equals("message")){
- Serial.println(type_msg + " "+ channel + " " + texto);
- tft.fillScreen(TFT_BLACK);
- tft.setTextColor(TFT_GOLD);
- tft.drawString("======Alert======", 10, 20, GFXFF);
- tft.drawString(texto, 10, 40, GFXFF);
- for (int i = 0; i <= 5; i++){
- buttonState=digitalRead(buttonPin);
- if (buttonState == LOW){
- i=0;
- break;
- }
- else {
- digitalWrite(vibePin, HIGH);
- delay(1000);
- digitalWrite(vibePin, LOW);
- delay(500); }
- }
- }
- }