4x4 Keypad program using polling

Dependencies:   KeypadLib mbed

main.cpp

Committer:
rlanghbv
Date:
2015-09-19
Revision:
1:97784d3b39e7
Parent:
0:c72d94fc465d

File content as of revision 1:97784d3b39e7:

#include "mbed.h"
#include "keypad.h"
 
Serial pc(USBTX, USBRX); 

 
int main() {
                //  c0   c1   c2   c3  r0   r1   r2   r3    
    Keypad keypad( PC_3,PC_2,PA_0,PA_1,PA_4,PB_0,PC_1,PC_0 );
       
    keypad.enablePullUp();
    char key;
    pc.printf("Please touch a key on the keypad\n\r");
    while (1) 
    {
         key = keypad.getKey();    
         if(key != KEY_RELEASED)
         {
             pc.printf("%c\r\n",key);
             wait(0.6);
         }
    }
}