Hate to post this, but I am googled out and tried many different options with no success.
Basically I would like to GET a page with the status of 10 lights and turn on/off the corresponding lights. The Arduino is getting the results and posting the string in the serial monitor, but the string is not triggering my if statements. Not sure if I am using the wrong function to parse the string or my if statements are incorrect.
Here is the output of the GET, which posts in the serial monitor (printing readString):
Light1:1
Light2:0
Light3:0
Light4:0
Light5:0
Light6:1
Light7:0
Light8:1
Light9:0
Light10:0
Here is the last thing I tried in the sketch, with an if statement for each light:
if (readString.indexOf("Light1:1">0))
{
digitalWrite(light1, HIGH);
}
else
{
digitalWrite(light1, LOW);
}
What function would you use? What am I doing wrong?
Restructuring the output of the page is also an option.
Possible typo… you’ve got your comparison inside the
.indexOf()call. Did you mean