Using a 16x2 LCD

Intro

The LiquidCrystal library allows you to control LCD displays compatible with the Hitachi HD44780 driver — the LCDs usually connected over a 16-pin interface.

This example prints “Hello World!” to the LCD and shows the time in seconds since reset.

Required Hardware

  • NEXTuino RISE/MAXI/MEGA (not Pure versions — 5V Pin Headers are needed)
  • 12/24V DC Power supply
  • 16×2 LCD
  • 10k ohm potentiometer
  • Hook-up wires

Circuit

You can use any communication, output, or input pin. The example uses UART and SPI pins (since they’re not needed here), freeing all I/O pins.

Connect the LCD according to the standard HD44780 16-pin wiring with the potentiometer adjusting contrast.

Note: Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the NEXTuino permanently!

Code

#include <LiquidCrystal.h>

// Initialize the library with the interface pins
LiquidCrystal lcd(1, 0, 53, 51, 50, 52);

void setup() {
  // Set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD:
  lcd.print("NEXTuino PEAK");
}

void loop() {
  // Set the cursor to column 0, line 1:
  lcd.setCursor(0, 1);
  // Print Hello World:
  lcd.print("Hello World!");
  delay(5);
}