Hola comunidad !!!, necesito su apoyo para ver como podrían interrumpir un ciclo for desde un botón de la pagina web que se llama off, este se apaga hasta terminar el ciclo, la placa que ocupo es una esp32, la intención es que un led se mantenga prendido mientras que el otro led parpadee de forma infinita, lo intente desde un ciclo while pero no me deja detenerlo y mi intención es que se pueda detener en cualquier momento presionando el boton, si me podrían ayudar como poderlo solucionar
#include <WiFi.h>
WiFiServer server(80);
const char* ssid = "ESP32-APP";
const char* password = "APPESP32";
String header;
String estadoSalida = "";
int led = 27;
int led2 =14;
String pagina = "<!DOCTYPE html>"
"<html>"
"<head>"
"<meta charset='utf-8' />"
"<style type='text/css'>body{color: orange; "
"background-image:url('https://www.paradavisual.com/wp-content/uploads/2021/01/2021-el-ano-de-la-robotica-y-la-inteligencia-artificial-2.jpg');"
"background-size:cover;}"
"h1{FONT-SIZE: 40pt;}</style>"
"<title> helicoptero </title>"
"</head>"
"<body>"
"<center>"
"<h2><a href='/led'><button style='height:300px;width:420px;color:white;border-radius:450px;background-color:#2894FF;FONT-SIZE: 40pt;'>ON</button></a></h2>"
"<h2><a href='/apd'><button style='height:300px;width:420px;color:white;border-radius:450px;background-color:#2894FF;FONT-SIZE: 40pt;'>OFF</button></a></h2>"
"</center></body></html>";
void setup() {
Serial.begin(115200);
Serial.println("");
pinMode(led,OUTPUT);
pinMode(led2,OUTPUT);
Serial.print("Punto de acceso habilitado...");
WiFi.softAP(ssid, password);
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP: ");
Serial.println(IP);
server.begin();
}
void loop() {
WiFiClient client = server.available();
if(client){
Serial.println("New Client.");
String currentLine = "";
while(client.connected()){
if(client.available()){
char c = client.read();
header += c;
if(c == '\n'){
if(currentLine.length() == 0){
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
if(header.indexOf("GET /led") >= 0){
Serial.println("GPIO led");
estadoSalida = "LED ON";
for(int i = 0; i<=255; i++){
digitalWrite(led, HIGH);
delay(150);
digitalWrite(led, LOW);
delay(150);
digitalWrite(led, HIGH);
digitalWrite(led2, HIGH);
}
} else if(header.indexOf("GET /apd") >= 0){
Serial.println("GPIO apd");
estadoSalida = "LED OFF";
digitalWrite(led, LOW);
digitalWrite(led2,LOW);
}
client.println(pagina);
client.println();
break;
}else{
currentLine = "";
}
}else if (c != '\r'){
currentLine += c;
}
}
}
header = "";
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}