In an older post, I reviewed the VEX LCD and provided some uses for it.  Now I will explain some of the commands to program the VEX LCD with ROBOTC.

Port Setup
To tell ROBOTC which port the LCD is plugged into, go to Robot > Motor and Sensors Setup

…and select the UART port you plugged your LCD into.  (Note about plugging in the LCD: The branch of the UART cord that has a orange-yellow wire goes in the left-hand port of the LCD, if the LCD is oriented with the VEX logo upright.)  Name the LCD whatever you’d like, and let the Baud Rate stay on the default.

Displaying Text
ROBOTC provides many functions for displaying text.  I find the most useful to be displayLCDString(nLine, nPos, sString) and displayLCDCenteredString(nLine, sString).  Where nLine is the line (values 0 or 1), nPos is the starting point of the string (values 0-15), and sString is the string to display (max 16 characters).  These are pretty self explanatory–the “plain” version allows you to set a starting position for the string, while the “centered” version automatically centers your string.

Clearing the Display
Eventually, you’ll want to clear the text you’ve displayed.  Use the clearLCDLine(nLine) function to clear a specified line (where, again, nLine is a 0 or a 1).

Using the Buttons
The currently pressed button is accessed using the variable nLCDButtons.  This variable has 4 possible values:
0: No button
1: Left button
2: Middle button
4: Right button
I don’t know why it’s numbered 0, 1, 2, 4–but it is, and we have to work with it.

To turn on the LCD backlight, set the Boolean variable bLCDBacklight to true.  A value of false (the default) will turn off the backlight.

Posted in Robot Programming, ROBOTC, Tutorial, VEX