I have an issue when I'm trying to hook an LCD display to my Arduino Uno Wifi Rev2. The LCD was shipped with the MKR IoT bundle, so I assume it's Arduino compatible.
It's my first attempt to connect this type of display, and I thought I'd start off with a sample code I found online and looks like this:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int lastUpdate = 0;
int currentIndex = 0;
char* lyrics[] = {
"Drink all the...",
" BOOZE! ",
"Hack all the... ",
" THINGS! "
};
void setup() {
lcd.begin(16, 2);
}
void loop() {
int time = millis();
if ((time - lastUpdate) >= 800)
{
lcd.setCursor(0, 0);
if (currentIndex == 0 || currentIndex == 2)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(lyrics[currentIndex]);
}
else
{
lcd.setCursor(0, 1);
lcd.print(lyrics[currentIndex]);
}
if (currentIndex == 3)
{
currentIndex = 0;
}
else
{
currentIndex += 1;
}
lastUpdate = time;
}
}
When compiling the sketch I get following errors:
Arduino: 1.8.11 (Windows 10), Board: "Arduino Uno WiFi Rev2, ATMEGA328"
C:\Users\x\OneDrive - Mynubo\Arduino\sketch_jun23b\sketch_jun23b.ino:12:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
};
^
C:\Users\x\OneDrive - Mynubo\Arduino\sketch_jun23b\sketch_jun23b.ino:12:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\x\OneDrive - Mynubo\Arduino\sketch_jun23b\sketch_jun23b.ino:12:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\x\OneDrive - Mynubo\Arduino\sketch_jun23b\sketch_jun23b.ino:12:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
In file included from C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp:1:0:
C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.h:45:36: error: expected class-name before '{' token
class LiquidCrystal : public Print {
^
C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.h:86:9: error: 'Print' has not been declared
using Print::write;
^~~~~
exit status 1
Error compiling for board Arduino Uno WiFi Rev2.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Any idea on how to solve this?
In the end I just want to use the LCD to show the value of a counter which keeps track of the number of times something passes a sensor. That code is working well so I just need the screen to work so I can complete the project.
Thanks!