Hello arduino gurus and noobs...
I have been trying to solve my problem, unfortunately, for a while now. I would like to have a function which will write to the appropriate I2C LCD based on a functions "String" input parameter. I'm having trouble determining how to code it correctly. Here is the code:
#include <Wire.h> // NEEDED FOR THE I2C COMM
#include <LiquidCrystal_I2C.h> // LCD FUNCTIONS LIBRARY
LiquidCrystal_I2C LEFT_lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
LiquidCrystal_I2C CENTER_lcd(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
LiquidCrystal_I2C RIGHT_lcd(0x25, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup(){
LEFT_lcd.begin(20,4); //// INITIALIZE THE 20x4 I2C LCD DISPLAY
CENTER_lcd.begin(20,4); //// INITIALIZE THE 20x4 I2C LCD DISPLAY
RIGHT_lcd.begin(20,4);
}
byte count = 0;
byte state = 0;
void loop(){
String lcd = " ";
if (state == 0){
lcd = "LEFT_lcd";
state++;
}else if (state == 1){
lcd = "CENTER_lcd";
state++;
}else{
lcd = "RIGHT_lcd";
state = 0;
}
Print_Menu(lcd);
Cursor_Refresh(lcd);
if(count <= 2)
count++;
else
count = 0;
delay(10000);
}
void Print_Menu(String lcd){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("* Smart-Shelf Menu *");
lcd.setCursor(0,1);
lcd.print(" Calibrate Product");
lcd.setCursor(0,2);
lcd.print(" Calibrate Scale");
lcd.setCursor(0,3);
lcd.print(" Exit");
}
void Cursor_Refresh(String lcd){
if (count == 0){
lcd.setCursor(0,1);
lcd.print("-->");
lcd.setCursor(0,2);
lcd.print(" ");
lcd.setCursor(0,3);
lcd.print(" ");
}
else if (count == 1){
lcd.setCursor(0,2);
lcd.print("-->");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,3);
lcd.print(" ");
}
else {
lcd.setCursor(0,3);
lcd.print("-->");
lcd.setCursor(0,2);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
}
}
Now I understand that the program seems ridiculous. I am trying to solve this problem using a small bit of the total code which I will then incorporate into the much larger code. The error I am getting, pertaining to this code, is:
'class String' has no member named 'clear'
'class String' has no member named 'setCursor'
...and one for all the other function calls which follow.
I believe there is something simple for which I am missing/not doing correctly. Thanks in advance for any help.