/*############################################################# Program Name : ex2_TextLCD_functions Author : Grant Phillips Date Modified : 03/05/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : Example program that demonstrates the use of the TextLCD library class functions (cls(), locate(), putc(), and printf()). Requirements : * STM32F4-Discovery Board Circuit : * The HD44780-based text LCD is connected as follows: Vss (LCD pin 1) - GND Vdd (LCD pin 2) - 3.3V Vee (pin3) - Contrast circuit RS (pin4) - PD8 RW (pin5) - GND E (pin6) - PD10 DB0 (pin7) - DB1 (pin8) - DB2 (pin9) - DB3 (pin10) - DB4 (pin11) - PD12 DB5 (pin12) - PD13 DB6 (pin13) - PD14 DB7 (pin14) - PD15 ##############################################################*/ #include "mbed.h" #include "TextLCD.h" //Simon Fords's class library (Jan 2014) //Create a TextLCD object with DigitalOut compatible pins) TextLCD lcd(PD_8, PD_10, PD_12, PD_13, PD_14, PD_15); // RS EN DB4 DB5 DB6 DB7 int main() { int i; wait(0.1); //100ms delay to allow lcd to initialize correctly lcd.printf("Hello World!"); //print text using printf while (1) { lcd.cls(); //clear the display wait(0.1); //at least 100ms delay always after cls() lcd.locate(0,0); //set the character cursor to col=0, row=0 lcd.printf("Hello World!"); //display text wait(0.5); lcd.locate(0,1); //set the character cursor to col=0, row=1 for(i=1;i<=8;i++) { lcd.printf("%d " , i); //print a integer value and space wait(0.5); } wait(1.0); lcd.cls(); //clear the display wait(0.1); //at least 100ms delay always after cls() lcd.locate(0,0); //set the character cursor to col=0, row=0 lcd.putc('G'); //display a character on the LCD lcd.putc('o'); lcd.putc('o'); lcd.putc('d'); lcd.putc(' '); lcd.putc('B'); lcd.putc('y'); lcd.putc('e'); lcd.locate(4,1); //set the character cursor to col=4, row=1 for(i=65;i<=72;i++) { lcd.putc(i); //display a integer value as a byte on the LCD; the //library will convert it to the correpsonding ASCII char wait(0.5); } wait(1.0); } }