Serial LCD test

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 
00003 Serial LCD
00004 
00005 This program is to demostrate the use of a Serial LCD
00006 
00007 Serial LCD used:
00008 http://www.skpang.co.uk/catalog/product_info.php?cPath=91_100_101&products_id=571
00009 
00010 v1.0 August 2010
00011 
00012 */
00013 
00014 
00015 #include "mbed.h"
00016 
00017 //LCD commands
00018 #define COMMAND 0xFE
00019 #define CLEAR   0x01
00020 #define LINE0   0x80
00021 #define LINE1   0xC0
00022 
00023 
00024 DigitalOut myled(LED1);
00025 Serial lcd(p9, p10);  // tx, rx
00026 
00027 int main() {
00028     wait(2);    //Wait for LCD to power up
00029     lcd.baud(9600);
00030     lcd.putc(COMMAND);
00031     lcd.putc(CLEAR);     //Clear screen
00032     
00033     lcd.printf("Hello World");
00034     
00035     lcd.putc(COMMAND);
00036     lcd.putc(LINE1);     //Set cursor to second line
00037     
00038     lcd.printf("www.skpang.co.uk");
00039 
00040     while(1) {
00041         myled = 1;
00042         wait(0.2);
00043         myled = 0;
00044         wait(0.2);
00045     }
00046 }