I am working with an XBee module, so naturally, I started my void loop with AT command testing.
void loop() {
digitalWrite(Sleep_Rq,LOW);
A +++ with a guard time of 1 sec before and after it, sets xbee module in command mode.
delay(1000);
xbeeSerial.write("+++"); // Enter Command Mode
delay(1000);
This part of the code, puts the serial data into string variable x in the form of a String.
while(xbeeSerial.available()) {
x = xbeeSerial.readString();
}
Serial.println() is returning OK onto the serial monitor.
Serial.println(x);
But when I compare x with OK nothing happens, 1 doesn't appear on the serial monitor.
if(x=="OK")
{
Serial.println(1);
}
}
I tried swapping "OK" with 4F4B (ascii equivalent of OK), 20299 (decimal value). I also tried changing datatype of x from String to word and compared x with 0100111101001011. I also tried changing the IF condition as,
if(Serial.println(x)=="OK")
{
Serial.println(1);
}
and many more techniques with no luck to be found.