UwU

Dependencies:   mbed TextLCD Keypad

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Keypad.h"
00003 #include "TextLCD.h"
00004 
00005 TextLCD lcd(PTB9,PTA1,PTB23,PTA2,PTC2,PTC3);
00006 Keypad kpad(PTC12,PTC4,PTD0,PTD2,PTD3,PTD1,PTE25,PTE24);
00007 Serial pc(USBTX,USBRX);
00008 int main(){
00009      char key;
00010     int released = 1;
00011 
00012     while(1){
00013         key = kpad.ReadKey();                   //read the current key pressed
00014 
00015         if(key == '\0')
00016             released = 1;                       //set the flag when all keys are released
00017            
00018         if((key != '\0') && (released == 1)) {  //if a key is pressed AND previous key was released
00019             pc.printf("%c\n", key);            
00020             released = 0;                       //clear the flag to indicate that key is still pressed
00021         }
00022         lcd.printf("%c",key);
00023     }   
00024 }