keypad corretto controllare il debounce
Dependencies: TextLCD keypad mbed
main.cpp@0:70e08bdedcba, 2018-05-13 (annotated)
- Committer:
- fdalforno
- Date:
- Sun May 13 10:41:12 2018 +0000
- Revision:
- 0:70e08bdedcba
keypad corretto
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fdalforno | 0:70e08bdedcba | 1 | #include "mbed.h" |
fdalforno | 0:70e08bdedcba | 2 | #include "TextLCD.h" |
fdalforno | 0:70e08bdedcba | 3 | #include "keypad.h" |
fdalforno | 0:70e08bdedcba | 4 | |
fdalforno | 0:70e08bdedcba | 5 | |
fdalforno | 0:70e08bdedcba | 6 | |
fdalforno | 0:70e08bdedcba | 7 | TextLCD lcd(D2,D3,D4,D5,D6,D7); |
fdalforno | 0:70e08bdedcba | 8 | |
fdalforno | 0:70e08bdedcba | 9 | Keypad telepad(PA_0 , PA_1 , PA_4 , PB_0,PA_13 , PA_14 , PC_2 , PC_3 ); |
fdalforno | 0:70e08bdedcba | 10 | |
fdalforno | 0:70e08bdedcba | 11 | |
fdalforno | 0:70e08bdedcba | 12 | int main() { |
fdalforno | 0:70e08bdedcba | 13 | lcd.locate(0,0); |
fdalforno | 0:70e08bdedcba | 14 | lcd.printf("KeyBoard: "); |
fdalforno | 0:70e08bdedcba | 15 | char key; |
fdalforno | 0:70e08bdedcba | 16 | while(1){ |
fdalforno | 0:70e08bdedcba | 17 | lcd.locate(0,1); |
fdalforno | 0:70e08bdedcba | 18 | key = telepad.getKey(); |
fdalforno | 0:70e08bdedcba | 19 | if(key != KEY_RELEASED){ |
fdalforno | 0:70e08bdedcba | 20 | lcd.printf( "%c" , key); |
fdalforno | 0:70e08bdedcba | 21 | wait(0.6); |
fdalforno | 0:70e08bdedcba | 22 | }else{ |
fdalforno | 0:70e08bdedcba | 23 | lcd.printf( "%c" , ' '); |
fdalforno | 0:70e08bdedcba | 24 | } |
fdalforno | 0:70e08bdedcba | 25 | } |
fdalforno | 0:70e08bdedcba | 26 | } |