Teclado por interrupciones

Dependencies:   keypad mbed

teclado.cpp

Committer:
jangelgm
Date:
2017-03-10
Revision:
0:7c2fe73deaa8

File content as of revision 0:7c2fe73deaa8:

#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   c3
                 
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(p21,p22,p23,p24,p25,p26,p27,p28);
         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]);
                }
}