Really simple program to preload into Nucleo boards to drive messages on the LCD shield for Ada Lovelace Day in ARM Sheffield

Dependencies:   TextLCD mbed

Committer:
MrBedfordVan
Date:
Wed Oct 05 16:40:24 2016 +0000
Revision:
0:59256585cc71
Really simple program to put on LCD Headers for ARM Sheffield Ada Lovelace Day

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MrBedfordVan 0:59256585cc71 1
MrBedfordVan 0:59256585cc71 2 // Simple ARM Sheffield Ada Lovelace LCD1602 KeyPad Thing
MrBedfordVan 0:59256585cc71 3 #include "mbed.h"
MrBedfordVan 0:59256585cc71 4 #include "TextLCD.h" // LCD1602
MrBedfordVan 0:59256585cc71 5
MrBedfordVan 0:59256585cc71 6 // Nucleo pins
MrBedfordVan 0:59256585cc71 7 TextLCD lcd(D8, D9, D4, D5, D6, D7);
MrBedfordVan 0:59256585cc71 8
MrBedfordVan 0:59256585cc71 9 // display text on LCD
MrBedfordVan 0:59256585cc71 10 void textLCD(char *text, int line) {
MrBedfordVan 0:59256585cc71 11 char tmpBuf[16];
MrBedfordVan 0:59256585cc71 12 for (int i = 0; i < 16; i++) tmpBuf[i] = 0x20;
MrBedfordVan 0:59256585cc71 13 for (int i = 0; i < strlen(text); i++) {
MrBedfordVan 0:59256585cc71 14 if (i < 16) tmpBuf[i] = text[i];
MrBedfordVan 0:59256585cc71 15 lcd.locate(i, line);
MrBedfordVan 0:59256585cc71 16 lcd.putc(tmpBuf[i]);
MrBedfordVan 0:59256585cc71 17 }
MrBedfordVan 0:59256585cc71 18
MrBedfordVan 0:59256585cc71 19
MrBedfordVan 0:59256585cc71 20 }
MrBedfordVan 0:59256585cc71 21
MrBedfordVan 0:59256585cc71 22 int main(){
MrBedfordVan 0:59256585cc71 23
MrBedfordVan 0:59256585cc71 24 lcd.cls();
MrBedfordVan 0:59256585cc71 25 while(1){
MrBedfordVan 0:59256585cc71 26
MrBedfordVan 0:59256585cc71 27 textLCD(" ARM Sheffield ", 0);
MrBedfordVan 0:59256585cc71 28 textLCD("Ada Lovelace Day", 1);
MrBedfordVan 0:59256585cc71 29 wait (10);
MrBedfordVan 0:59256585cc71 30 textLCD("Not really doing", 0);
MrBedfordVan 0:59256585cc71 31 textLCD("much yet is it? ", 1);
MrBedfordVan 0:59256585cc71 32 wait (10);
MrBedfordVan 0:59256585cc71 33 textLCD("Try programming ", 0);
MrBedfordVan 0:59256585cc71 34 textLCD("it instead ", 1);
MrBedfordVan 0:59256585cc71 35 wait (10);
MrBedfordVan 0:59256585cc71 36
MrBedfordVan 0:59256585cc71 37 } // while
MrBedfordVan 0:59256585cc71 38 } //main