teste teclado

Dependencies:   mbed Keypad

principal_keypad.cpp

Committer:
enricoan
Date:
2020-05-27
Revision:
0:5b3b34d4e428

File content as of revision 0:5b3b34d4e428:

#include "mbed.h"
#include "Keypad.h"

Keypad teclado(PA_6, PA_7, PF_6, PC_7, PB_7, PC_13, PC_14, PC_15);

int main() {
    char tecla;
    int solta = 1;

    while(1){
        tecla = teclado.ReadKey();                   //read the current key pressed

        if(tecla == '\0')
            solta = 1;                       //set the flag when all keys are released
            
        if((tecla != '\0') && (solta == 1)) {  //if a key is pressed AND previous key was released
            printf("%c\n", tecla);            
            solta = 0;                       //clear the flag to indicate that key is still pressed
        }
    }
}