Page 299 - ARM Based Microcontroller Projects Using MBED
P. 299
10.2 PROJECT 1—DISPLAYING TEXT ON THE LCD 285
10.2.5 Program Listing
ThereareseveralLCDlibrariesforMbed.InthisprojectwehaveusedtheonecalledTextLCD.
Before using the library we must import it into our workspace. The steps are as follows:
• Right click on your project folder (LCDText) in the Program Workspace.
• Click Import Library -> From Import Wizard….
• Enter TextLCD in the search box at the top right-hand side of the screen (see Fig. 10.3) and
click Search.
• Double click on TextLCD with the tag HD44780 TextLCD.
• You should see the library listed in your project folder.
The program listing (program: LCDText) is shown in Fig. 10.4. At the beginning of the pro-
gram header files mbed.h and TextLCD.h are included in the program. The interface between
the LCD and the development board must be defined at the beginning of the program by
specifying the GPIO pins that are connected to the LCD pins in the following order:
R/S, E, D4, D5, D6, D7
Inside the main program the text Nucleo-F411RE is displayed on the LCD.
10.2.6 LCD Library Functions
The LCD library used in this project supports a number if useful functions for controlling
the text to be displayed on the LCD. These functions are as follows:
cls: Clear the screen
putc: Write a character on the LCD
printf: Write a formatted string on the LCD
locate(column, line): Position the cursor at the given column and line
10.2.7 Suggestions for Additional Work
Modify the program given in Fig. 10.4 so that the text is displayed starting from column 2 of
the second line of the LCD.
FIG. 10.3 Search for the LCD library.