try1 with keypad

Dependencies:   keypad mbed

Committer:
nostradamus2x
Date:
Tue Nov 07 01:12:28 2017 +0000
Revision:
2:05f7cf34c118
Parent:
1:a045dce72999
Child:
3:74062f7daedd
NC kiya. for the column not being used

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nostradamus2x 0:5151ad0261b3 1 #include "mbed.h"
nostradamus2x 0:5151ad0261b3 2 #include "Keypad.h"
nostradamus2x 0:5151ad0261b3 3
nostradamus2x 0:5151ad0261b3 4 // Define your own keypad values
nostradamus2x 0:5151ad0261b3 5 char Keytable[] = { '1', '2', '3', 'A', // r0
nostradamus2x 0:5151ad0261b3 6 '4', '5', '6', 'B', // r1
nostradamus2x 0:5151ad0261b3 7 '7', '8', '9', 'C', // r2
nostradamus2x 0:5151ad0261b3 8 '*', '0', '#', 'D', // r3
nostradamus2x 0:5151ad0261b3 9 };
nostradamus2x 0:5151ad0261b3 10 // c0 c1 c2
nostradamus2x 0:5151ad0261b3 11
nostradamus2x 0:5151ad0261b3 12 uint32_t Index;
nostradamus2x 2:05f7cf34c118 13 uint32_t
nostradamus2x 0:5151ad0261b3 14 uint32_t cbAfterInput(uint32_t index) {
nostradamus2x 0:5151ad0261b3 15 Index = index;
nostradamus2x 1:a045dce72999 16 PwmOut r(LED_RED);
nostradamus2x 0:5151ad0261b3 17 return 0;
nostradamus2x 0:5151ad0261b3 18 }
nostradamus2x 0:5151ad0261b3 19
nostradamus2x 0:5151ad0261b3 20 int main() {
nostradamus2x 1:a045dce72999 21 // r0 r1 r2 r3 c0 c1 c2 c3
nostradamus2x 1:a045dce72999 22 Keypad keypad(PTE5, PTE4, PTE3, PTE2, PTB11, PTB10, PTB9, NC);
nostradamus2x 0:5151ad0261b3 23 keypad.attach(&cbAfterInput);
nostradamus2x 0:5151ad0261b3 24 keypad.start(); // energize the keypad via c0-c3
nostradamus2x 1:a045dce72999 25 PwmOut r(LED_BLUE);
nostradamus2x 1:a045dce72999 26
nostradamus2x 0:5151ad0261b3 27 while (1) {
nostradamus2x 0:5151ad0261b3 28 __wfi();
nostradamus2x 0:5151ad0261b3 29 printf("Interrupted\r\n");
nostradamus2x 0:5151ad0261b3 30 printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
nostradamus2x 0:5151ad0261b3 31 }
nostradamus2x 0:5151ad0261b3 32 }