Up to this point, we have done communication between the Launchpad and the human user using blinking LEDs, sounds, and the serial monitor. In this project, we introduce the inexpensive 2 line by 16 character LCD display.
These displays allow us to communicate text messages to the user without requiring another computer to display them.
The photo above shows such a display. This one has white letters on a blue background, lit by an internal white LED backlight.
The display is powered by 5 volts, so we need to get the power from the TP1 test point on the Launchpad, as we did when we used the Sonar sensor. Pin 1 on the LCD display is ground, and Pin 2 is 5 volts. The third pin controls the contrast of the display. I find that a simple 1k ohm resistor between this pin and ground gives nice contrast on the display. To make the contrast adjustable, you can connect a potentiometer between ground and 5 volts, and connect the wiper terminal of the potentiometer to pin 3. I find it is usually not necessary.
Pin 15 and 16 are connected to 5 volts and ground to light the LED backlight. You can add a resistor between pin 15 and 5 volts to dim the LED and save some battery power if you like.
Pin 4 on the LCD display is the Register Select. When low, data coming in is interpreted as a command. When high, data coming in is text to display. We connect this pin to the Launchpad's P1.0 pin.
Pin 6 is the Clock Enable pin. We connect that to the Launchpad's P2.1 pin.
The data pins are 11 through 14. We connect these to the Launchpad's P2.2, P2.3, P2.4 and P2.5 pins.
The bottom view of the board shows that we have connected pins 16 and 1 with a jumper, and pins 15, 5, and 2 with two more jumpers.
The Launchpad and display can be seen connected together in the photo below.
The Energia software comes with a library that makes sending text to the LCD display very simple. Printing the words "Hi there!" is as easy as this:
The library contains code that lets you select the row and column where you wish to print, code for clearing the screen, and other simple functions. It also has an "autoscroll" function that turns on a feature in the module that is supposed to make it easy to send characters that scroll off the screen when new characters come in. However, it seems to behave in strange ways, jumping from one row to the other at strange times. But since writing code to scroll properly is not difficult and takes up little space in the Launchpad, I just wrote my own code when I wanted a program to receive serial data from other devices and display it on the LCD panel.
When you load that program onto the Launchpad, whatever you type in the top line of the Serial Monitor gets displayed on the LCD screen. To actually see it handling special characters like carriage return, line feed, and backspace, you will want something a little better than the Serial Monitor, such as HyperTerminal, PuTTY, or some other terminal emulation program running on your computer.