37 lines
861 B
C++
37 lines
861 B
C++
// include the library code:
|
|
#include <Arduino.h>
|
|
#include <LiquidCrystal.h>
|
|
|
|
// initialize the library by associating any needed LCD interface pin
|
|
// with the arduino pin number it is connected to
|
|
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
|
|
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
|
|
char buffer_line1[16];
|
|
char buffer_line2[16];
|
|
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
// set up the LCD's number of columns and rows:
|
|
lcd.begin(16, 2);
|
|
lcd.clear();
|
|
}
|
|
|
|
void loop() {
|
|
while (Serial.available() == 0) {}
|
|
lcd.clear();
|
|
lcd.setCursor(0, 0);
|
|
String s1 = Serial.readStringUntil('\n'); // This fixed performance issue
|
|
int nl_idx = s1.indexOf("?", 0);
|
|
if (nl_idx == -1) {
|
|
lcd.print(s1);
|
|
}
|
|
else {
|
|
String s2 = s1.substring(nl_idx+1, s1.length());
|
|
s1 = s1.substring(0, nl_idx);
|
|
lcd.print(s1);
|
|
lcd.setCursor(0, 1);
|
|
lcd.print(s2);
|
|
}
|
|
}
|