keypad test for the CORE-1000

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
odb
Date:
Wed Mar 21 08:20:38 2018 +0000
Parent:
5:0815efcb0008
Commit message:
CORE-1000_keypad

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0815efcb0008 -r 902b4b31fb35 main.cpp
--- a/main.cpp	Wed Nov 09 12:23:33 2016 +0000
+++ b/main.cpp	Wed Mar 21 08:20:38 2018 +0000
@@ -1,12 +1,29 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
-
+DigitalOut clkout(PA_8);
+DigitalIn keyin(PB_4 );
+Serial pc(USBTX, USBRX);
+int oldkey;
+int getkey(void)
+{
+    int cnt;
+    int num = 0;
+    for(cnt = 1; cnt < 17; cnt++)
+    {
+        clkout = 0;
+        if(keyin == 0)   
+        num = cnt;
+        clkout = 1;
+    }     
+     printf("num = %d \n\r", num);     
+    return num;
+}
 int main() {
+    pc.baud(115200);
     while(1) {
-        myled = 1; // LED is ON
-        wait(0.2); // 200 ms
-        myled = 0; // LED is OFF
-        wait(1.0); // 1 sec
+        int newkey = getkey();
+        printf("key pressed = %d \n\r", newkey);
+        oldkey = newkey;
+        wait(0.2);
     }
-}
+}
\ No newline at end of file