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

Revision:
3:39825a5cf7cf
Parent:
2:ad0b044d0a10
Child:
4:e97e3c1442d2
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Thu Jan 22 15:47:19 2015 +0000
@@ -1,10 +1,67 @@
 // Hello World! for the TextLCD
 
 #include "mbed.h"
-#include "TextLCD.h"
+#include "TextLCD.h"//LCD bibliotek
+#include "rtos.h"//threading bibliotek
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd_txt(p26, p25, p24, p23, p22, p21,TextLCD::LCD20x4); // rs, e, d4-d7
+DigitalOut Led1 (LED1);
+DigitalOut Led2 (LED2);
+DigitalOut MyLed (p28);
+
+DigitalIn Btn1 (p27);
+
+
+
 
-int main() {
-    lcd.printf("Hello World!\n");
+void CheckBtn_thread(void const *args) 
+{
+    while (true) //tråd der scanner knapper
+    {
+        Led2 = !Led2;
+        if (MyLed == true)
+          {
+            lcd_txt.locate(0,2);
+            lcd_txt.printf("LED aktiveret!  ");   
+          }
+          else
+          {
+            lcd_txt.locate(0,2);
+            lcd_txt.printf("LED deaktiveret!");   
+          }
+        
+        
+         lcd_txt.locate(0,0);
+         lcd_txt.printf("***** SuperTue *****");
+        
+        if (Btn1 == true)//scanner knap
+        {
+          lcd_txt.locate(0,3);
+          lcd_txt.printf("Switch aktiv!");
+          MyLed = !MyLed; //tænder og slukker for diode
+          Thread::wait(500);
+        }
+        else
+        {
+          lcd_txt.locate(0,3);
+          lcd_txt.printf("                    ");
+         } 
+         
+          
+    }
+
+ }
+
+int main() 
+{
+    Thread thread(CheckBtn_thread);
+    lcd_txt.cls();
+    
+    while (true) 
+    {
+      Led1 = !Led1; //starter "tråd" i hovedprogram
+      Thread::wait(500);
+    }
+
 }
+