Seeedstudio Arch Examples : Grove Serial LCD - Print strings and numbers

Dependencies:   Grove_Serial_LCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SerialLCD.h"
00003  
00004 SerialLCD lcd(P1_13, P1_14);  /* Grove Serial LCD is connected to UART Tx and Rx pins*/
00005  
00006 int main() {
00007     int a=0;    
00008     char strBuffer[16];
00009     
00010     lcd.begin();                 /* initialize Serial LCD communication. */ 
00011     lcd.print("mbed with Arch"); /* print text */
00012     
00013     while (1) {
00014          
00015         lcd.setCursor(0, 1);         /* set cursor at 0th column and 1st row */
00016         sprintf(strBuffer, "%d", a); /* prepare a string buffer to print number */   
00017         lcd.print(strBuffer);        /* print the string buffer */
00018         wait(0.1);                   /* wait 100ms */ 
00019         a++;
00020     }
00021 }