// Ensure Serial Monitor has "No Line Ending"
/*
The purpose of this code is to be able to both enter text into the serial command line, store it to memory, and display it on the LCD screen.
If the text exceeds 16 chars, it is rejected by the code (ver I)
"newWordFlag" ensues the word doesn't print continously. "printFlip" ensures the word only prints once
*/
#include <EEPROM.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
bool newWordFlag = false;
int len;
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
lcd.setCursor(0, 1);
lcd.print("System Ready");
while (!Serial) {}
Serial.println("System Ready");
}
void loop() {
len = EEPROM.read(24);
if (Serial.available() > 0) { // Captures input from serial
newWordFlag = true;
lcd.clear();
String line_1 = Serial.readString();
Serial.print("Received: ");
Serial.println(line_1);
len = line_1.length();
EEPROM.write(24, len);
for (int i = 0; i <= len; i++) {
EEPROM.write(25 + i, line_1[i]);
}
}
if (newWordFlag) {
//newWordFlag = true;
for (int j = 25; j <= len + 24; j++) {
lcd.print((char)EEPROM.read(j));
Serial.print((char)EEPROM.read(j));
Serial.println();
newWordFlag = false;
}
//Serial.print("Broken"); // Used to test conditional, Enters "for"?
//Serial.println();
}
}