This example prints "Hello World!" to the LCD and makes the cursor block blink.
Dependencies: Hotboards_SpiLcd mbed
main.cpp@0:8d56048bea6a, 2016-02-02 (annotated)
- Committer:
- Hotboards
- Date:
- Tue Feb 02 21:29:14 2016 +0000
- Revision:
- 0:8d56048bea6a
First release: Hotboards_SpiLcd_Blink
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:8d56048bea6a | 1 | /* |
Hotboards | 0:8d56048bea6a | 2 | LiquidCrystal Library - Blink |
Hotboards | 0:8d56048bea6a | 3 | Demonstrates the use a 16x2 LCD display. The Hotboards_SpiLcd |
Hotboards | 0:8d56048bea6a | 4 | library works with all LCD displays that are compatible with the |
Hotboards | 0:8d56048bea6a | 5 | ST7032 driver presented on Spi Lcd board (http://www.hotboards.org). |
Hotboards | 0:8d56048bea6a | 6 | This sketch prints "Hello World!" to the LCD and makes the |
Hotboards | 0:8d56048bea6a | 7 | cursor block blink. |
Hotboards | 0:8d56048bea6a | 8 | The circuit: |
Hotboards | 0:8d56048bea6a | 9 | * BKL --> GND |
Hotboards | 0:8d56048bea6a | 10 | * VDD --> 3.3v |
Hotboards | 0:8d56048bea6a | 11 | * GND --> GND |
Hotboards | 0:8d56048bea6a | 12 | * SCK --> PA_5 |
Hotboards | 0:8d56048bea6a | 13 | * SI --> PA_6 |
Hotboards | 0:8d56048bea6a | 14 | * CS --> PB_15 |
Hotboards | 0:8d56048bea6a | 15 | * RS --> PB_14 |
Hotboards | 0:8d56048bea6a | 16 | * RST --> PB_13 |
Hotboards | 0:8d56048bea6a | 17 | Library and example ported by Diego from Hotboards and originally cretaed by |
Hotboards | 0:8d56048bea6a | 18 | by David A. Mellis |
Hotboards | 0:8d56048bea6a | 19 | library modified 5 Jul 2009 |
Hotboards | 0:8d56048bea6a | 20 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:8d56048bea6a | 21 | example added 9 Jul 2009 |
Hotboards | 0:8d56048bea6a | 22 | by Tom Igoe |
Hotboards | 0:8d56048bea6a | 23 | modified 22 Nov 2010 |
Hotboards | 0:8d56048bea6a | 24 | by Tom Igoe |
Hotboards | 0:8d56048bea6a | 25 | This example code is in the public domain. |
Hotboards | 0:8d56048bea6a | 26 | */ |
Hotboards | 0:8d56048bea6a | 27 | #include "mbed.h" |
Hotboards | 0:8d56048bea6a | 28 | #include <Hotboards_SpiLcd.h> |
Hotboards | 0:8d56048bea6a | 29 | |
Hotboards | 0:8d56048bea6a | 30 | /* initialize an instance of SPI bus,setting the SPI pins*/ |
Hotboards | 0:8d56048bea6a | 31 | SPI device(PA_7,PA_6,PA_5); /* SO, SI, SCK*/ |
Hotboards | 0:8d56048bea6a | 32 | /* initialize the library with the numbers of the interface pins*/ |
Hotboards | 0:8d56048bea6a | 33 | Hotboards_SpiLcd display( device, PB_15, PB_14, PB_13 ); /* SPI, CS, RS, RST */ |
Hotboards | 0:8d56048bea6a | 34 | |
Hotboards | 0:8d56048bea6a | 35 | int main() |
Hotboards | 0:8d56048bea6a | 36 | { |
Hotboards | 0:8d56048bea6a | 37 | /* set the spi frequency to 5MHz*/ |
Hotboards | 0:8d56048bea6a | 38 | device.frequency(5000000); |
Hotboards | 0:8d56048bea6a | 39 | /* initialize internal lcd controller:*/ |
Hotboards | 0:8d56048bea6a | 40 | display.init(); |
Hotboards | 0:8d56048bea6a | 41 | |
Hotboards | 0:8d56048bea6a | 42 | // Print a message to the LCD. |
Hotboards | 0:8d56048bea6a | 43 | display.printf("hello, world!"); |
Hotboards | 0:8d56048bea6a | 44 | |
Hotboards | 0:8d56048bea6a | 45 | while(1) |
Hotboards | 0:8d56048bea6a | 46 | { |
Hotboards | 0:8d56048bea6a | 47 | // Turn off the blinking cursor: |
Hotboards | 0:8d56048bea6a | 48 | display.noBlink(); |
Hotboards | 0:8d56048bea6a | 49 | wait(3); |
Hotboards | 0:8d56048bea6a | 50 | // Turn on the blinking cursor: |
Hotboards | 0:8d56048bea6a | 51 | display.blink(); |
Hotboards | 0:8d56048bea6a | 52 | wait(3); |
Hotboards | 0:8d56048bea6a | 53 | } |
Hotboards | 0:8d56048bea6a | 54 | } |