UwU

Dependencies:   mbed TextLCD Keypad

main.cpp

Committer:
gabocs
Date:
2019-11-14
Revision:
25:d8698a7bc5be
Parent:
24:7f14b70fc9ef

File content as of revision 25:d8698a7bc5be:

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

TextLCD lcd(PTB9,PTA1,PTB23,PTA2,PTC2,PTC3);
Keypad kpad(PTC12,PTC4,PTD0,PTD2,PTD3,PTD1,PTE25,PTE24);
Serial pc(USBTX,USBRX);
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
            pc.printf("%c\n", key);            
            released = 0;                       //clear the flag to indicate that key is still pressed
        }
        lcd.printf("%c",key);
    }   
}