Chat freely about anything...

User avatar
By sophiazz
#88508 ESP32 PROBLEM IN COMPARING TWO SAME STRINGS#80923
By moonlight7 - Wed Mar 06, 2019 1:58 am
i am receiving "on" or "off" in msg. yet when i am comparing msg to "on" and "off" here, it is
not working.........what to do?

void loop() {
// put your main code here, to run repeatedly:
Serial.println("waiting for a message (subscribe)");
PubSubClient* client = PubNub.subscribe(channel);
if (!client) {
Serial.println("subscription error");
delay(1000);
return;
}
String msg;

SubscribeCracker ritz(client);
while (!ritz.finished()) {
ritz.get(msg);
if (msg.length() > 0) {
Serial.print("Received: ");
Serial.println(msg);
if(msg.equals("on"))
{digitalWrite(5,HIGH);
Serial.println("thik h...");}

if(msg == "off\n")
{digitalWrite(5,LOW);
Serial.println("thik h...");}


}}}