Simple program for the TextLCD library, with switch and LED

Dependencies:   TextLCD TextLCD_HelloWorld_SuperTue mbed-rtos mbed

Fork of TextLCD_HelloWorld_SuperTue by Tue Myren

Committer:
myren
Date:
Wed May 17 08:19:20 2017 +0000
Revision:
5:3c663dd80a47
Parent:
4:e97e3c1442d2
SuperTue's Praktikant Program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 1:7418a52375a0 1 // Hello World! for the TextLCD
simon 1:7418a52375a0 2
simon 0:334327d1a416 3 #include "mbed.h"
myren 4:e97e3c1442d2 4 #include<string>
myren 3:39825a5cf7cf 5 #include "TextLCD.h"//LCD bibliotek
myren 3:39825a5cf7cf 6 #include "rtos.h"//threading bibliotek
simon 0:334327d1a416 7
myren 4:e97e3c1442d2 8
myren 3:39825a5cf7cf 9 TextLCD lcd_txt(p26, p25, p24, p23, p22, p21,TextLCD::LCD20x4); // rs, e, d4-d7
myren 3:39825a5cf7cf 10 DigitalOut Led1 (LED1);
myren 3:39825a5cf7cf 11 DigitalOut Led2 (LED2);
myren 4:e97e3c1442d2 12 DigitalOut MyLed (p29);
myren 4:e97e3c1442d2 13
myren 4:e97e3c1442d2 14 DigitalIn Btn1 (p28);
myren 3:39825a5cf7cf 15
myren 4:e97e3c1442d2 16 int PressCounter =0;
myren 4:e97e3c1442d2 17 string LCD_Text;;
myren 4:e97e3c1442d2 18 bool KnapAktiv;
simon 0:334327d1a416 19
myren 3:39825a5cf7cf 20 void CheckBtn_thread(void const *args)
myren 3:39825a5cf7cf 21 {
myren 3:39825a5cf7cf 22 while (true) //tråd der scanner knapper
myren 3:39825a5cf7cf 23 {
myren 4:e97e3c1442d2 24
myren 3:39825a5cf7cf 25 if (Btn1 == true)//scanner knap
myren 3:39825a5cf7cf 26 {
myren 3:39825a5cf7cf 27 lcd_txt.locate(0,3);
myren 3:39825a5cf7cf 28 lcd_txt.printf("Switch aktiv!");
myren 3:39825a5cf7cf 29 MyLed = !MyLed; //tænder og slukker for diode
myren 4:e97e3c1442d2 30 Thread::wait(100);
myren 4:e97e3c1442d2 31
myren 3:39825a5cf7cf 32 }
myren 3:39825a5cf7cf 33 else
myren 3:39825a5cf7cf 34 {
myren 4:e97e3c1442d2 35 Thread::wait(100);
myren 3:39825a5cf7cf 36 lcd_txt.locate(0,3);
myren 3:39825a5cf7cf 37 lcd_txt.printf(" ");
myren 3:39825a5cf7cf 38 }
myren 3:39825a5cf7cf 39
myren 3:39825a5cf7cf 40
myren 3:39825a5cf7cf 41 }
myren 3:39825a5cf7cf 42
myren 3:39825a5cf7cf 43 }
myren 3:39825a5cf7cf 44
myren 3:39825a5cf7cf 45 int main()
myren 3:39825a5cf7cf 46 {
myren 3:39825a5cf7cf 47 Thread thread(CheckBtn_thread);
myren 3:39825a5cf7cf 48 lcd_txt.cls();
myren 4:e97e3c1442d2 49 lcd_txt.locate(0,0);
myren 5:3c663dd80a47 50 lcd_txt.printf("****TestProgram*****");
myren 4:e97e3c1442d2 51 //LCD_Text ="****TestProgram****";
myren 4:e97e3c1442d2 52 //lcd_txt.printf("%s",LCD_Text);
myren 4:e97e3c1442d2 53
myren 4:e97e3c1442d2 54 while (true)
myren 4:e97e3c1442d2 55 {
myren 3:39825a5cf7cf 56
myren 4:e97e3c1442d2 57 }
myren 4:e97e3c1442d2 58
simon 0:334327d1a416 59 }
myren 3:39825a5cf7cf 60