Once you’ve mastered learning some of the microcontroller basics such as digital input and output and lighting and blinking a few LED’s, you may wonder what next ? We’ll the natural progression is to have a display that improveds a microcontroller’s usefulness. A few LED’s as indicators is great but nothing beats having some human readable feedback. Once an LCD display is incorporated into your projects it increased the level of a user interface and you can start displaying collected data in real time without the use of a computer. Some of the things that can be displayed are sensor readings like temperature, humidity, GPS positioning or even a simple ON/OFF indication.
The most common type of LCD is the 16 x 2 display that uses the Hitachi HD44780 (or compatible) chipset. It has 2 lines each of 16 alpha numeric characters. The LCD interfaces to the microcontroller using a parallel data bus. The the user can chose a either 4 or 8 bit data transmission. While using a 4 bit transmission is slower that an 8 bit transmission, it only uses 4 pins plus the RS, Enable and RW (optional) pins. So by using 4 bits you can use a minimum of 6 I/O pins of the microcontroller freeing up 4 extra I/O pins for doing other tasks like such as control or monitoring. Some LCD displays can use the I2C interface which only uses one pin but we will not look into that for this post.
Components Needed to interface the LCD to an Arduino
- Arduino Uno (or compatible board)
- USB cable
- Arduino IDE
- 16×2 LCD display shield based on the HD44780 chipset
- LiquidCrystal.h library
Wiring up the LCD
We have used a third party 16×2 LCD shield but you can just as easily use a stand alone 16×2 LCD. The important part is that the wiring is done correctly which depends on the type of LCD you are using and whether you are using it in 4 or 8 bit mode. For this exercise we will be using the 4 bit mode.
Code to display text on a 16×2 LCD display.
The code we are using is to demonstrate how to write text on the first line of the display.
LCD (HD44780) interfacing to Arduino and microcontrollers
Using a 16×2 LCD (HD44780) display in your project can be quite simple using the “LiquidCrystal.h” library that is built into the Arduino IDE. It allows you to incorporate feedback text in your projects that makes the user experience more pleasant than having no display at all. Using an LCD display also allow a project to be independent of a computer to view live or storeded data making the project portable. Our next project builds on this post by adding a DHT11 Temperature and humidity sensor and displays live readings on LCD display.
We hope this tutorial has been useful to you. If you liked this post please share it with a friend !
Before you move on, I would love for you to suggest some topics you would like to see covered on the Smartmicrocontroller.com website this year by leaving a comment in the comments section in the youtube channel, or send us a message through one of the social media links on the about page.