I'm trying to create a project withe the ESP32 which will allow me to control two pwm lines via wifi. I'm relatively inexperienced when it comes to programming, but eager to learn. Having got an LED to turn on and off with the help of the SimpleWiFiServer sketch, I thought I could try to parse the duty cycle info for the URL. However, it does not seem to work. Below is the relevant section of my code.
int pwmChannelA = 0;
if(currentLine.indexOf("pwmchannelA=") != -1 ){ //we find pwmchannelA
int aindex = currentLine.indexOf("pwmchannelA=") + 12; //get to index after =
String pwmChannelAString = currentLine.substring(aindex); //typecast number to int
pwmChannelA = pwmChannelAString.toInt(); //convert to int
}
if(pwmChannelA <100){ //LED off if <100, on otherwise
digitalWrite(5, LOW);
}
if(pwmChannelA >=100){
digitalWrite(5,HIGH);
}
However, I get no response. What am I doing wrong here? As my int could be any number of digits from one to three I dont want to explicitly declare indexing values, and in the future I might want to add additional 'tags' for determining the value I'm changing - pwm a, pwm b, etc etc.
Apologies in advance for my noob-ness, any questions I will be happy to answer.