user33278: I need to update my global variable once I get a 'overdtrue' response and light up my LED but only my LED is lighting up but my global variable is not updated.
Here is my code
int x = 0;

void loop() { 
if (content.indexOf("ovrdtrue") > 0)
 {
  x++;
  digitalWrite(ledPin, HIGH);

 }
fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
Serial.print("X: ");
Serial.println(x);
}

The x value should be 1 but only the LED has light up. Please help.


user33278: It seems like I forgot to include an if else condition above the ovrdtrue.
if(content.indexOf("true") > 0)
{
  digitalWrite(ledPin, HIGH);   

}

Arduino is reading this condition even though the data received "ovrdtrue" but this contains some word "true" so this is the one getting read and not the ovrdtrue condition. I just changed the condition variable not close to the word true and it worked fine. I'm sorry for this.

33278: <p>I need to update my global variable once I get a 'overdtrue' response and light up my LED but only my LED is lighting up but my global variable is not updated.</p>

<p>Here is my code</p>

<pre><code>int x = 0;

void loop() { 
if (content.indexOf("ovrdtrue") &gt; 0)
 {
  x++;
  digitalWrite(ledPin, HIGH);

 }
fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
Serial.print("X: ");
Serial.println(x);
}
</code></pre>

<p>The x value should be 1 but only the LED has light up. Please help.</p>

<p><a href="https://i.stack.imgur.com/pXfSh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pXfSh.jpg" alt="enter image description here"></a></p>
 33278: <p>It seems like I forgot to include an if else condition above the ovrdtrue.</p>

<pre><code>if(content.indexOf("true") &gt; 0)
{
  digitalWrite(ledPin, HIGH);   

}
</code></pre>

<p>Arduino is reading this condition even though the data received "ovrdtrue" but this contains some word "true" so this is the one getting read and not the ovrdtrue condition. I just changed the condition variable not close to the word true and it worked fine. I'm sorry for this.</p>
