Bought a HDM16216H-5-S00S 16x2 LCD display from mouser.com (no backlighting), can't get it to do much of anything with LiquidCrystal library, either 4 data lines or 8. Got it soldered onto a Nano Every. Here's the "datasheet" link from mouser:
https://www.mouser.com/datasheet/2/178/16216h5-18812.pdf
Tried 10K pot 5V to GND with wiper to LCD pin 3, get it to flash some solid blocks occasionally (about 1/2 of one line). Tried a 4.7K resister to GND on pin 3. No luck. Just a blank screen. I've got RW tied to GND.
The Nano (and, therefore, the LCD) are powered over the USB.
Writing the code in the IDE (not web), with Registers emulation: "None (ATMEGA4809)"
Here's my code. The RBn pins defined at the top are not connected (and not used). They are left over from a prior attempt.
// test_LiquidCrystal_lib
#include <LiquidCrystal.h>
static const uint8_t RESET = 13; // Built-in LED
static const uint8_t RS = 5;
static const uint8_t RW = 11;
static const uint8_t ENABLE = 12;
static const uint8_t DB0 = A3;
static const uint8_t RB0 = 6;
static const uint8_t DB1 = A2;
static const uint8_t RB1 = 7;
static const uint8_t DB2 = A1;
static const uint8_t RB2 = 8;
static const uint8_t DB3 = A0;
static const uint8_t RB3 = 9;
static const uint8_t DB4 = A6;
static const uint8_t RB4 = 3;
static const uint8_t DB5 = A7;
static const uint8_t RB5 = 2;
static const uint8_t DB6 = 4;
static const uint8_t RB6 = 0; // RX
static const uint8_t DB7 = 1; // TX, old 23 (AREF)
static const uint8_t RB7 = 10;
//LiquidCrystal lcd(RS, RW, ENABLE, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7);
LiquidCrystal lcd(RS, ENABLE, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7);
//LiquidCrystal lcd(RS, ENABLE, DB4, DB5, DB6, DB7); // Tie RW to GND
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
//lcd.noAutoScroll();
//lcd.noCursor();
//lcd.setCursor(col, row); sets location where subsequent text written to the LCD will be displayed
lcd.print("Hello World!");
Serial.begin(9600);
Serial.setTimeout(500); // mSec
Serial.println("setup done");
help();
}
void help(void) {
Serial.println();
Serial.println("H - help");
Serial.println("C - clear");
Serial.println("W<col>,<row>,<text> - write");
Serial.println();
}
byte swallow(byte c) {
// Returns 1 on success.
byte b = Serial.read();
if (b == c) return 1;
Serial.print("Expected '");
Serial.print(c);
Serial.print("', got '");
Serial.print(b);
Serial.println("'");
return 0;
}
void write(void) {
byte col = Serial.parseInt(SKIP_WHITESPACE);
if (!swallow(',')) return;
byte row = Serial.parseInt(SKIP_WHITESPACE);
if (!swallow(',')) return;
String text = Serial.readStringUntil('\n');
Serial.print("Writing ");
Serial.print(text.length());
Serial.print(" chars to position ");
Serial.print(col);
Serial.print(", ");
Serial.println(row);
lcd.print(text);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()) {
byte c = Serial.read();
switch (toupper(c)) {
case 'H': help(); break;
case 'C': lcd.clear(); Serial.println("LCD cleared"); break;
case 'W': write(); break;
case ' ': case '\t': case '\r': case '\n': break;
default: help(); break;
}
}
}