Code works properly, except when I try to compare the incoming string (labeled 'str') to a string that I have declared in my code (labeled 'purchase').
A String is NOT a string.
String str = client->getResponseBody();
Serial.print("Who's beer is this?:':");
Serial.print(str);
//Refresh the LCD before displaying the most current cell contents
lcd.clear();
//The following was written by Goet:https://forum.arduino.cc/index.php?topic=216486.0 to center the contects on the LCD screen
int pinnedRow = 0; // LCDHEIGHT / 2;
String pinnedText = str;
int l = pinnedText.length();
lcd.setCursor(l % 2 == 0 ? LCDWIDTH / 2 - (l / 2) : LCDWIDTH / 2 - (l / 2) - 1, pinnedRow);
pinnedText= pinnedText.substring(0, pinnedText.length() - 2);
lcd.print (pinnedText);
//Read Data from cell D1, if it matched the string "Beer Purchased", then open the solenoid for x seconds (or turn off back light for testing purposes)
if (client->GET(url3, host)){
++connect_count;
//assign the outpult string ofthe readD3 Google appps function to a string called 'flag'
String str= client->getResponseBody();
Serial.print("Output from Google Sheet: ");
Serial.print(str);
}
else{
++error_count;
DPRINT("Error-count while connecting: ");
Serial.print("First Error while connecting");
DPRINTLN(error_count);
}
String purchase = "Beer Purchased";
Serial.print("Output from 'purchase' string: ");
Serial.print(purchase);
if(str == purchase){
Which str do you think you are comparing to purchase? Dollars to donuts it is NOT the one you think is being compared.