Displaying text on LCD screen from the Arduino UNO

By: (plus.google.com) +David Herron; Date: June 17, 2017

Tags: Arduino

The Arduino doesn't have an intrinsically native display. Programmers frequently debug their software by printing stuff to a screen, or they need a human-machine-interface to show what's happening, and even a simple text display can be quite handy.

With this article we'll install a particular kind of LCD display, and learn how to drive the LCD display using the LiquidCrystal library. This particular LCD requires wiring up a little circuit that uses a potentiometer to control brightness. While we might yearn for a simple-to-connect-display, we do learn a little electronics along the way. At the end of the day the Arduino is about encouraging us to fire up our soldering iron and making things.

Once you've wired the display, the LiquidCrystal library makes it easy to display text on the screen.

The LiquidCrystal library runs on Arduino, and supports LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset. These are widely available and very inexpensive.

ESUMIC LCD Module for Arduino 20 x 4, White on Blue, based on the popular HD44780 controller
ESUMIC LCD Module for Arduino 20 x 4, White on Blue, based on the popular HD44780 controller:
RioRand LCD Module for Arduino 20 x 4, White on Blue
RioRand LCD Module for Arduino 20 x 4, White on Blue:

While the first of these is the one I used, both claim to be compatible with the HD44780 and therefore the following instructions are suitable for both.

Wiring the LCD display board

Wiring diagram to attach the LCD display to an Arduino

The video below goes through the process of wiring such a display using this wiring diagram. It's useful to compare between this diagram and what is done in the video.

In that video the wiring is performed on a prototyping breadboard. The display boards shown above have simple holes on a PC board to which you solder wires, whereas in the video he clearly pushes the display into holes in the breadboard.

My wiring of the LCD display to an Arduino

The Arduino I purchased came in a kit with a breadboard and a bunch of jumper wires. I should have wired the display as in the video, with components on a breadboard. But this LCD doesn't have a way to securely connect the jumper wires. That's because the LCD display board simply has holes, and while you can stick the jumper wires in the holes they don't stay in place. Pondering the gizmos in front of me, I decided to instead solder components to a small circuit board.

I'm afraid my soldering job wasn't good, and the connection is a little flaky - the display flickers out if you move it around, fixed by adjusting the wires.

Connecting the LCD display, adjusting brightness

However you choose to wire it, the first step is to adjust the display contrast. This is controlled by setting the potentiometer until the display looks right.

Simply connect it to the Arduino, then turn on the Arduino. While there is no default text displayed, some blocks and other things will show up letting you adjust the potentiometer.

Installing the LiquidCrystal library, quickie sample programs

Library Manager showing the LiquidCrystal library

Before printing text to the LCD we need to make sure the LiquidCrystal is installed. As with all other Arduino libraries, you do this via the Library Manager section of the IDE. Simply enter LiquidCrystal in the search box and it shows up as shown here. If you need to install that library, it's done from here.

Downloading the HelloWorld sample application for use with the LCD display

In the Sketch the wiring of the LCD display to the Arduino is documented.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

For example, that section in the comments is the same as wiring diagram.

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

This line of code actually informs the LiquidCrystal library what Arduino pins to use in communicating with the display. Of course they match the wiring diagram.

lcd.begin(16, 2);

This line in setup configures the display size. The displays shown above has 20 columns by 4 rows, while this line of code configures the display for 16 lines by 2 rows.

lcd.begin(20, 4);

Change it to this if you have a 20x4 display as suggested above.

lcd.print("hello, world!");

This looks simple doesn't it? The LiquidCrystal library takes this and works out the graphics to show the text. The display we've chosen here accepts graphics commands, not text commands. Behind the scenes of this command there's a lot going on, but we don't have to worry about that.

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);
}

Here is the loop of this Sketch, meaning that this function execute repeatedly. The setCursor command moves the text cursor to the first column (column 0) of the second line of the display (line 1). The subsequent lcd.print command takes the current time, printing it on the screen at the location of the text cursor.

Final result -- the number counts the number of milliseconds since the Arduino booted

Links

LiquidCrystal library - (www.arduino.cc) https://www.arduino.cc/en/Reference/LiquidCrystal

How to Set Up and Program an LCD on the Arduino - YouTube

Source: (www.youtube.com) Circuit Basics

How to Set Up and Program an LCD on the Arduino In this video, I briefly show you how to connect a 16x2 LCD to an Arduino. After that, I go in-depth into whi...
« Arduino board and accessories buying guide. Arduino UNO first step, connect to your laptop, run a simple application »
2016 Election Acer C720 Ad block AkashaCMS Amiga Android Anti-Fascism Apple Apple Hardware History Apple iPhone Hardware April 1st Arduino ARM Compilation Astronomy Asynchronous Programming Authoritarianism Automated Social Posting Bells Law Big Brother Black Holes Blade Runner Blogger Blogging Books Botnet Botnets Cassette Tapes Cellphones Christopher Eccleston Chrome Chrome Apps Chromebook Chromebooks Chromebox ChromeOS CIA CitiCards Civil Liberties Clinton Cluster Computing Command Line Tools Computer Hardware Computer Repair Computers Cross Compilation Crouton Curiosity Rover Cyber Security Cybermen Daleks Darth Vader Data backup Data Storage Database Database Backup Databases David Tenant DDoS Botnet Detect Adblocker Digital Photography DIY DIY Repair Docker Doctor Who Doctor Who Paradox Drobo Drupal Drupal Themes DVD Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Emdebian Enterprise Node ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Facebook Fake News File transfer without iTunes FireFly Fraud Freedom of Speech Gallifrey git Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Home Automation HTTPS I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick InfluxDB Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices iPad iPhone iPhone hacking Iron Man Iternet of Things iTunes Java JavaScript JavaScript Injection JDBC John Simms Joyent Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac OS Mac OS X Make Money Online MariaDB Mars Matt Lucas MEADS Anti-Missile Mercurial Michele Gomez Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications MODBUS Mondas Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Node Web Development Node.js Node.js Database Node.js Testing Node.JS Web Development Node.x North Korea Online advertising Online Fraud Open Media Vault Open Source Governance Open Source Software OpenAPI OpenVPN Personal Flight Peter Capaldi Photography PHP Plex Media Server Political Protest Postal Service Power Control Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero Recycling Remote Desktop Republicans Retro-Technology Reviews Right to Repair River Song Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Scheme Science Fiction Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Shell Scripts Silence Simsimi Skype Social Media Warfare Social Networks Software Development Space Flight Space Ship Reuse Space Ships SpaceX Spring Spring Boot SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Swagger Synchronizing Files Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Torchwood Total Information Awareness Trump Trump Administration Ubuntu UDOO Virtual Private Networks VirtualBox VLC VNC VOIP Web Applications Web Developer Resources Web Development Web Development Tools Weeping Angels WhatsApp Wordpress YouTube