/*
Forum: https://forum.arduino.cc/t/lcd-displaying-white-lines-s0lv3d/1312714
Wokwi: https://wokwi.com/projects/412097242415977473
Test of "LiquidCrystal_I2C.h" and "Adafruit_LiquidCrystal.h"
by using the I2C example from
https://github.com/adafruit/Adafruit_LiquidCrystal/blob/master/examples/HelloWorld_i2c/HelloWorld_i2c.ino
"Adafruit_LiquidCrystal.h" connects but shows only a blank screen
"LiquidCrystal_I2C.h" connects and displays as expected
2024/10/18
ec2021
*/
// Outcomment the following line to use "LiquidCrystal_I2C.h" instead of "Adafruit_LiquidCrystal.h"
#define ORIGINAL
/*
Demonstration sketch for Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander
( https://learn.adafruit.com/i2c-spi-lcd-backpack )
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4
*/
#ifdef ORIGINAL
// include the library code:
#include "Adafruit_LiquidCrystal.h"
// Connect via i2c, default address #0 (A0-A2 not jumpered)
Adafruit_LiquidCrystal lcd(7);
#else
#include "LiquidCrystal_I2C.h"
const byte I2C_ADDR = 0x27;
const byte LCD_COLUMNS = 16;
const byte LCD_LINES = 2;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
#endif
void setup() {
Serial.begin(115200);
// while(!Serial);
Serial.println("LCD Character Backpack I2C Test.");
// set up the LCD's number of rows and columns:
#ifdef ORIGINAL
if (!lcd.begin(16, 2)) {
Serial.println("Could not init backpack. Check wiring.");
while(1);
}
#else
lcd.begin(16,2);
#endif
Serial.println("Backpack init'd.");
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW);
delay(500);
}