try1 with keypad

Dependencies:   keypad mbed

keyo.cpp

Committer:
nostradamus2x
Date:
2017-11-07
Revision:
0:5151ad0261b3
Child:
1:a045dce72999

File content as of revision 0:5151ad0261b3:

#include "mbed.h"
#include "Keypad.h"
 
 // Define your own keypad values
 char Keytable[] = { '1', '2', '3', 'A',   // r0
                     '4', '5', '6', 'B',   // r1
                     '7', '8', '9', 'C',   // r2
                     '*', '0', '#', 'D',   // r3
                   };
                  // c0   c1   c2 
 
 uint32_t Index;
 
 uint32_t cbAfterInput(uint32_t index) {
     Index = index;
     return 0;
 }
 
 int main() {
                 // r0    r1    r2    r3    c0     c1     c2     c3
     Keypad keypad(PTE5, PTE4, PTE3, PTE2, PTB11, PTB10, PTB9, PTB8);
     keypad.attach(&cbAfterInput);
     keypad.start();  // energize the keypad via c0-c3
 
     while (1) {
         __wfi();
         printf("Interrupted\r\n");
         printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
     }
 }