Connect a Parallax Serial LCD to your project

Most applications have some kind of user feedback. In many cases a simple led is all you need. But in some cases you want more verbose feedback. This is where a display comes in.
Although you can use a fancy OLED display that can even show video all we want in most cases is just plain characters. This tuturial shows 2 different ways how you can easily add a 2 x 16 character LCD display to your A-blocks application.

For this tutorial we use a parallax seriel LCD screen with 2 x 16 characters and a backlight (part #27977). The LCD only has only 3 connections on the back. The connections are exposed through 3 standard 0.1" pins

1. GND
2. 5V
3. RX

Connecting to an analog port
We start off by the simplest solution, in which no soldering is required. Here we make use of the fact that we can use an anlog input port also as a digital output port. The serial LCD can be connected to the analog port with a standard sensor cable. Be sure to connect it the correct way. The black wire is GND, the red wire 5V and the white wire the IO.
Once the LCD is connected we need some code to drive it. To use an analog pin as digital you address the pin with a digital port number. This number is the analog port number + 14 (analog port 0 is digital port 14, analog 1 is digital 15, etc). So we can declare the pin as output and use the NewSoftSerial library to communicate with the LCD.
// The serial rx (10) is not used
// the tx is on port 18, this is analog port 4

NewSoftSerial lcd(10, 18);

void setup()
{
  pinMode(18, OUTPUT);
  lcd.print("Hello world");
}

That's all!

Connecting to a digital port
The second way to connect a serial LCD is through a digital port. In this case a bit of easy soldering is required. To connect to the serial LCD we use a small A-blocks prototype board. We start by soldering a 3 pin female receptor on it. Then we wire the output pins of the prototype board to the female receptor. The picture below shows you the connections to make.
If you run the DIO2 (rx) wire on top of the board and the GND and 5V below you get a board like this.
The prototype board will fit nicely below the LCD
The code to drive the LCD is almost identical to the code used for the analog solution above. The only thing we do is remove the pinMode statement in the set() function:
// The serial rx (10) is not used
// the tx is on port 8, we used digital port D5 here

NewSoftSerial lcd(10, 8);

void setup()
{
  lcd.print("Hello world");
}

That's all there is to it. 2 simple ways to add a serial LCD. More information about the parallax serial LCD we used can be found in this datasheet Parallax serial LCD
Shopping cart