Juan Angel García
/
Teclado
Teclado por interrupciones
Diff: teclado.cpp
- Revision:
- 0:7c2fe73deaa8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/teclado.cpp Fri Mar 10 09:20:17 2017 +0000 @@ -0,0 +1,30 @@ +#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]); + } +}