// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
String text[] = {"The quick brown", "fox jumps over", "The lazy doge.", "then sits on the", "very angry cat.", "With a crunch", "and a bang", "and a bing", "and a bong",};
String input;
int currentPage = 0;
int lenMax = (sizeof(text) / sizeof(text[0])) - 2;
void setup() {
lenMax = (sizeof(text) / sizeof(text[0])) - 2;
text[lenMax + 1] = "testing 123";
Serial.begin(115200);
lcd.begin(16, 2);
Serial.println(lenMax-2);
// you can now interact with the LCD, e.g.:
printPage();
}
void printPage()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(text[currentPage]);
lcd.setCursor(0,1);
lcd.print(text[currentPage + 1]);
}
void loop() {
switch((char)Serial.read())
{
case 'w':
Serial.print("up");
Serial.println(currentPage);
Serial.println(lenMax);
if (currentPage < lenMax) {
currentPage++;
printPage();
}
Serial.println(currentPage);
break;
case 's':
if(currentPage > 0){
currentPage--;
printPage();
Serial.print("down");
Serial.println(currentPage - lenMax);
break;
}
}
}