// With the hd44780 library.
// Using example:
// https://github.com/duinoWitchery/hd44780/blob/master/examples/ioClass/hd44780_I2Cexp/HelloWorld/HelloWorld.ino
//
// Similar project with an Arduino Uno:
// https://wokwi.com/projects/453451078117780481
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd;
char BluePill[] = "You take the Blue Pill, the story ends, you wake up in your bed and believe whatever you want to believe.";
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
Serial.begin(115200);
Serial.print("SDA is assigned to pin ");
Serial.println(SDA);
Serial.print("SCL is assigned to pin ");
Serial.println(SCL);
Wire.begin();
delayMicroseconds(30);
Serial.print("Scanning I2C bus: ");
bool found = false;
for(int address=1; address<128; address++)
{
Wire.beginTransmission(address);
if(Wire.endTransmission() == 0)
{
Serial.print("0x");
if(address < 0x10)
Serial.print("0");
Serial.print(address,HEX);
Serial.print(", ");
found = true;
}
}
if(!found)
Serial.print("Nothing found");
Serial.println();
int status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
Serial.println("Error, display not found");
// hd44780 has a fatalError() routine that blinks an led if possible
// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
Serial.println("No error. Print something on LCD display.");
lcd.print("Hello");
}
void loop() {}