UwU
Dependencies: mbed TextLCD Keypad
Diff: main.cpp
- Revision:
- 25:d8698a7bc5be
- Parent:
- 24:7f14b70fc9ef
diff -r 7f14b70fc9ef -r d8698a7bc5be main.cpp --- a/main.cpp Mon Apr 08 11:03:25 2019 +0100 +++ b/main.cpp Thu Nov 14 20:59:42 2019 +0000 @@ -1,12 +1,24 @@ #include "mbed.h" +#include "Keypad.h" +#include "TextLCD.h" -DigitalOut myled(LED1); +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; -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); - } -} + 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); + } +} \ No newline at end of file