Hotboards MX / Mbed 2 deprecated Hotboards_SpiLcd-Hello_World

Dependencies:   Hotboards_SpiLcd mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002   Hotboards_SpiLcd Library - Hello World
00003   
00004   Demonstrates the use a 16x2 LCD display.  The Hotboards_SpiLcd
00005   library works with all LCD displays that are compatible with the
00006   SP7032 driver presented on Spi Lcd board (http://www.hotboards.org).
00007   
00008   This sketch prints "Hello World!" to the LCD
00009   and shows the time.
00010   
00011   The circuit:
00012   *  BKL   -->  GND
00013   *  VDD   -->  3.3v
00014   *  GND   -->  GND
00015   *  SCLK  -->  PB_3
00016   *  SI    -->  PB_5
00017   *  CS    -->  PC_0
00018   *  RS    -->  PC_1
00019   *  RST   -->  PC_2
00020  
00021   Library and example ported by Diego from Hotboards and originally cretaed by
00022   by David A. Mellis
00023   library modified 5 Jul 2009
00024   by Limor Fried (http://www.ladyada.net)
00025   example added 9 Jul 2009
00026   by Tom Igoe
00027   modified 22 Nov 2010
00028   by Tom Igoe
00029   This example code is in the public domain.
00030  */
00031  
00032 #include "mbed.h"
00033 #include "Hotboards_SpiLcd.h"
00034  
00035 // initialize the spi peripherals, setting the spi pins 
00036 SPI device( PB_5, NC, PB_3 ); // mosi, miso, sclk
00037 // initialize the library with the numbers of the interface pins
00038 Hotboards_SpiLcd display( device, PC_0, PC_1, PC_2 ); //spi, cs, rs, rst
00039  
00040 int main( void ) 
00041 {
00042     uint8_t milis = 0;
00043     // set the spi frequency to 5MHz
00044     device.frequency(5000000);
00045     // initialize internal lcd controller:
00046     display.init();
00047     // Print a message to the LCD.
00048     display.printf( "Hello mbed!" );
00049     
00050     while(1)
00051     {
00052         // set the cursor to column 0, line 1
00053         // (note: line 1 is the second row, since counting begins with 0):
00054         display.setCursor( 0, 1 );
00055         wait( 1 );
00056         milis++;
00057         // print the number of seconds since reset:
00058         display.printf( "  %d", milis );
00059     }
00060 }