Practica_6_-_Ejercicio_04
Dependencies: mbed TextLCD Keypad
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "Keypad.h" 00004 TextLCD lcd(PTE24, PTE25, PTD1, PTD3, PTD2, PTD0, TextLCD::LCD16x2); // rs, e, d4-d7 00005 Keypad kpad(PTA2, PTB23, PTA1, PTB9, PTC4, PTC12, PTC3, PTC2); 00006 DigitalIn borrador(PTC17); 00007 int main() { 00008 char key; 00009 int released = 1; 00010 00011 while(1){ 00012 if(borrador){ //Testear la dualidad del botón borrador con el ejercicio 3. 00013 lcd.cls(); 00014 } 00015 else{ 00016 key = kpad.ReadKey(); //read the current key pressed 00017 00018 if(key == '\0') 00019 released = 1; //set the flag when all keys are released 00020 00021 if((key != '\0') && (released == 1)) { //if a key is pressed AND previous key was released 00022 lcd.printf("%c", key); 00023 released = 0; //clear the flag to indicate that key is still pressed 00024 } 00025 } 00026 } 00027 }
Generated on Fri Jul 15 2022 19:14:37 by 1.7.2