Projeto Mecatrônico
/
TESTE_teclado_separado
teste teclado
Revision 0:5b3b34d4e428, committed 2020-05-27
- Comitter:
- enricoan
- Date:
- Wed May 27 17:26:51 2020 +0000
- Commit message:
- teste teclado separado
Changed in this revision
diff -r 000000000000 -r 5b3b34d4e428 Keypad.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keypad.lib Wed May 27 17:26:51 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/grantphillips/code/Keypad/#4bbd88022a6f
diff -r 000000000000 -r 5b3b34d4e428 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 27 17:26:51 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
diff -r 000000000000 -r 5b3b34d4e428 principal_keypad.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/principal_keypad.cpp Wed May 27 17:26:51 2020 +0000 @@ -0,0 +1,21 @@ +#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 + } + } +}
diff -r 000000000000 -r 5b3b34d4e428 teste_biblio_keypad.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/teste_biblio_keypad.cpp Wed May 27 17:26:51 2020 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "Keypad.h" + +Keypad teclado(PC_0, PC_1, PB_0, PA_4, PC_3, PC_2, PC_15, PC_14); +DigitalOut mled(LED1); + +int main() { + char tecla; + int solta = 1; + + while(1){ + mled = 1; // LED is ON + wait(0.2); // 200 ms + mled = 0; // LED is OFF + wait(1.0); // 1 sec + + 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 + } + } +}