Watch The Video Tutorial

LCDs are alphanumeric (or graphical) displays, which are frequently used in microcontroller-based applications.
TherThere are many types of LCD devices in the market which come in different shapes and sizes.
Some LCDs have 40 or more character lengths with the capability to display several lines.
Some other LCD displays can be programmed to display graphic images. Some modules offer color displays, while some others incorporate back lighting so that they can be viewed in dimly lit conditions. /> In terms of interfacing technique, we can group them in two categories: Parallel LCDs and serial LCDs. Parallel LCDs like the popular Hitachi HD44780 series are connected to the microcontroller circuitry such that data is transferred to the LCD using more than one line and usually four data lines (4-bit mode) or eight data lines (8-bit mode) are used.
Refer to the article Interfacing LCD Display With PIC Microcontroller to learn more on the connection of LCD display.

Typical connection of an LCD display to a PIC Microcontroller

Figure 1: Typical connection of an LCD Display to PIC Microcontroller

For most PIC programming languages, the LCD is often one of the last things you learn as it is quite complicated to get working. However, in Flowcode you don’t need to know what is going on inside, all you have to do is drag and drop some few icons on the flowchart and flowcode will sort out the rest for you.

—>>To insert an LCD display component, on the components tool bar click on LCD under the Outputs group.
An LCD (LCDDisplay(0)) will be inserted on the panel.

Figure 2: Inserting an LCD component

—>> Select the LCD then click on the “….” next to connections properties of the LCD to open its connection properties. Here you can set the Port that the LCD is connected to, and the individual pins for the various connections.

Figure 3: Pin Connections

—>>Click again on the “….” next to the Ext Properties to edit the LCD properties. Here you can choose various properties such as LCD size, Text size (for simulation) and so on.

Figure 4: LCD properties

LCD Size: The drop down list allows a number of different LCD sizes to be set.
Size is Characters x Rows. The default LCD size is 16×2 i.e. 2 rows of 16 characters.
Currently supported sizes include (Flowcode v5.0.3):
8×1              16×1             20×1                40×1
8×2              16×2            20×2                40×2
8×4              16×4            20×4

Component Macros

Drag and drop the Component Macros from the Icons toolbar.

Figure 5: Component Macro

Double click the component macro to open its properties. Click on the LCDDisplay(0) to see its macros.
The LCD Component provides the following macros:

Start() 
The start macro must be called once to initialise the LCD display before any other LCD component macros are called.

Figure 6: Initialize LCD

Clear() 

This macro clears the LCD display.

PrintASCII(BYTE Character)
Prints the ASCII characters at the current cursor position. Once the characters have been printed, the cursor position is automatically advanced. Characters can be either an ASCII character code or a string of one or more characters surrounded by double quotes, or a standard ASCII character surrounded by single quotes.

Command(BYTE in) 
Send the command signal value in to the LCD display. Command can be used to configure the display and to send data and instructions directly to the LCD.

Cursor(x, y) 
This macro positions the cursor at a given x and y coordinate. Here you can choose to print at the beginning of the screen (0,0), in the middle, at the bottom line of the display and so on. In this demonstration below, the cursor is moved to the beginning of the second line of the display.

Figure 7: LCD Cursor

PrintNumber(BYTE number or INT number)
Prints the number supplied.
E.g. passing in the number 10 will cause “10” to be displayed on the LCD.
passing in the number 0xA1 will cause “161” to be displayed on the LCD or
passing in the number 0b101 will cause “5” to be displayed on the LCD.
Once the character has been printed, the cursor position is automatically advanced. Also compatible with INTegers.

PrintString(STRING String)
Prints the String at the current cursor position. Once the characters have been printed, the cursor position is automatically advanced. The String is printed until a NULL string termination character is encountered (the end of the assigned characters in the string).
A string of characters to be printed can be surrounded by double quotes as shown below on figure 8:
“Hello World” will be displayed on the LCD screen or a string variable can be inserted as an expression as shown below on figure 9 and 10:  a variable Display[20] is set to “LCD Display” PrintString(Display) will display on the screen “LCD Display”, just 11 characters not 20 as the string is terminated after the LCD Display.

Figure 8: Print String

Figure 9: Creating a string variable

Figure 10: Printing a string variable

ScrollDisplay(BYTE Direction, BYTE Num_Positions)
Scrolls the display data left or right by a number of positions specified by the Num_Positions variable.
If the Direction byte is 0, ‘l’ or ‘L’ then the LCD data will scroll to the left. If the Direction byte is 1, ‘r’ or ‘R’ then the LCD data will scroll to the right.

ClearLine(BYTE Line_Number) 
Clears an entire line of the display and then returns the cursor back to the start of the line.

RAM_Write(BYTE nIdx, BYTE D0, BYTE D1, BYTE D2, BYTE D3, BYTE D4, BYTE D5, BYTE D6, BYTE D7)
Modifies the internal memory of the LCD device to allow for up to 8 customised characters to be created and stored into the device memory. Custom characters are referenced by using a nIdx parameter of 0 – 7 to specify the customised character you wish to edit. The Dx bytes define the 8 data columns that are associated with the custom character.
To print out the custom charater on the display use the PrintASCII macro using the number as the Character parameter.
NOTE. This macro does not simulate.
Let us create a circuit as shown on the figure 1 above and display “Hello World” on the first row of the LCD and “LCD Display” on the second row.

You can download the full project files (Flowcode and Proteus Schematic design) below here.

All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).  

Download LCD Flowcode Project
Download LCD Proteus Flowcode