Practica_6_-_Ejercicio_03
Dependencies: mbed TextLCD Keypad
main.cpp
- Committer:
- isaacross99
- Date:
- 2019-11-20
- Revision:
- 32:03bfdca818b6
- Parent:
- 31:080589c1250a
File content as of revision 32:03bfdca818b6:
#include "mbed.h" #include "TextLCD.h" #include "Keypad.h" TextLCD lcd(PTE24, PTE25, PTD1, PTD3, PTD2, PTD0, TextLCD::LCD16x2); // rs, e, d4-d7 Keypad kpad(PTA2, PTB23, PTA1, PTB9, PTC4, PTC12, PTC3, PTC2); int main() { char key; int released = 1; while(1){ key = kpad.ReadKey(); //read the current key pressed if(key == '\0') released = 1; //set the flag when all keys are released if((key != '\0') && (released == 1)) { //if a key is pressed AND previous key was released lcd.printf("%c", key); released = 0; //clear the flag to indicate that key is still pressed } } }