inp.remove(0,16) will modify inp, removing the first 16 characters. There is no return value from remove(), so you cannot set another String to the non-existent return value.
if (charlength >= 17) {
inp.remove(0,16);
lcd.write(inp);
}
#include <LiquidCrystal.h>
// initialize the library by associating LCD pins
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
byte smiley[8] = {
0b00000,
0b00000,
0b01010,
0b00000,
0b00000,
0b10001,
0b01110,
0b00000
};
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hi");
lcd.createChar(1,smiley);
lcd.print("I ");
lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte
lcd.print(" Arduino! ");
lcd.setCursor(9,0);
lcd.write((byte)1);
delay(3000);
lcd.clear();
}
void loop() {
// AUJAS type a note over here so you understand what is going on.
int seconds = millis() / 1000;
lcd.setCursor(0,0);
if (Serial.available()>0){
String inp = Serial.readStringUntil("\n");
int charlength = inp.length();
if (charlength >= 17) {
String data = inp;
data.remove(0,16);
lcd.setCursor(0,1);
lcd.write(data);
}
else{
lcd.write(inp);
}
delay(20000);
lcd.clear();
}
if(seconds >= 120 && Serial.available()==0){
Serial.print("sleeping...");
}
}
Post the complete set of error messages between code tags. There is a button to copy the error messages, above and on the right side of where the messages appear on the IDE.
write is used to write byte values to the LCD, either a single byte, or a number of bytes if you also specify how many as a 2nd argument to the write function. write does not know what to do with a String.
print is overloaded to accepts may different types of data, one of which is String, so it is able to send that to the LCD.