prueba teclado matricial 4x3

Dependencies:   TextLCD mbed

Fork of LCD_test by proyectotecnicas

Files at this revision

API Documentation at this revision

Comitter:
Diegolorca
Date:
Mon Nov 30 03:49:51 2015 +0000
Parent:
0:a9f60dff8cb6
Commit message:
prueba de teclado matricial 4x3 usando interrupcion la salida se observa en el LCD externo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Nov 26 21:18:11 2015 +0000
+++ b/main.cpp	Mon Nov 30 03:49:51 2015 +0000
@@ -1,26 +1,37 @@
 #include "mbed.h"
 #include "TextLCD.h"
-#include "AnalogIn.h"
+
+
+TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
+
+DigitalIn key1(PTC1);
+DigitalIn key2(PTC2);
+DigitalIn key3(PTB3);
+DigitalIn key4(PTB2);
+InterruptIn Enable(PTA2);
 
-AnalogIn leer(PTC1);
+int num, B1,B2,B3,B4;
 
-TextLCD lcd(PTE20, PTE21, PTE22, PTE23, PTB20, PTE30, TextLCD::LCD16x2);
-
+void func()
+{
+    lcd.cls();
+    lcd.printf(" %d ", num);
+    wait(1);
+    lcd.cls(); 
+}
+    
 int main() {
 
-float lectura;
-float voltaje;
-
-    while(1){
+    while(1)
+    {    
     
-    lectura = leer.read();
-    voltaje = lectura*3.3;
-    lcd.cls();
-    lcd.printf("%f",lectura);
-    lcd.locate(1,1);
-    lcd.printf("%f", voltaje);
-    wait(2);
+    B1 = key1.read();
+    B2 = key2.read();
+    B3 = key3.read();
+    B4 = key4.read();
     
+    num = 2*2*2*B1 + 2*2*B2 + 2*B3 + B4;
     
+    Enable.rise(&func);
     }
 }