LCD interfacing with Switch

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Eduvance
Date:
Tue May 27 07:29:09 2014 +0000
Parent:
0:dea0c97faf15
Commit message:
A

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r dea0c97faf15 -r 4e5a747ab6eb TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue May 27 07:29:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r dea0c97faf15 -r 4e5a747ab6eb main.cpp
--- a/main.cpp	Mon May 19 10:27:43 2014 +0000
+++ b/main.cpp	Tue May 27 07:29:09 2014 +0000
@@ -1,12 +1,46 @@
 #include "mbed.h"
+#include "TextLCD.h"
 
-DigitalOut myled(LED1);
+DigitalIn psw(p14);
+DigitalIn psw1(p15);
+DigitalIn psw2(p16);
+DigitalIn psw3(p17);
+
+TextLCD lcd(p25, p24, p23, p22, p21, p20, TextLCD::LCD16x2); 
+int loop =10;
 
 int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
-    }
+  lcd.cls();                      //  clear LCD screen
+    lcd.printf(" switch and LCD ");
+    lcd.locate(0,1);
+    lcd.printf("A= ,B= ,C= ,D= ");
+  while (loop>0){
+      if (psw == 1)
+      {lcd.locate(2,1);
+      lcd.printf("1");
+      }
+      else {lcd.locate(2,1);
+            lcd.printf("0");}
+      if (psw1 == 1)
+      {lcd.locate(6,1);
+      lcd.printf("1");
+      }
+      else {lcd.locate(6,1);
+            lcd.printf("0");}
+       
+      
+      if (psw2 == 1)
+      {lcd.locate(10,1);
+      lcd.printf("1");
+      }
+      else {lcd.locate(10,1);
+            lcd.printf("0");} 
+            
+      if (psw3 == 1)
+      {lcd.locate(14,1);
+      lcd.printf("1");
+      }
+      else {lcd.locate(14,1);
+            lcd.printf("0");}      
 }
+}