Keypad buzzer lcd for stm32f407vg
Dependencies: mbed beep TextLCD keypad
main.cpp@0:3a5f00390207, 2018-12-08 (annotated)
- Committer:
- omerbguclu
- Date:
- Sat Dec 08 09:52:36 2018 +0000
- Revision:
- 0:3a5f00390207
Omer Buyukguclu
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
omerbguclu | 0:3a5f00390207 | 1 | #include "mbed.h" |
omerbguclu | 0:3a5f00390207 | 2 | #include "keypad.h" |
omerbguclu | 0:3a5f00390207 | 3 | #include "TextLCD.h" |
omerbguclu | 0:3a5f00390207 | 4 | #include "beep.h" |
omerbguclu | 0:3a5f00390207 | 5 | //STM32F4-Discovery |
omerbguclu | 0:3a5f00390207 | 6 | |
omerbguclu | 0:3a5f00390207 | 7 | TextLCD lcd(PC_1, PC_0, PC_3, PC_2, PA_1, PA_0);// rs e d4-d7 |
omerbguclu | 0:3a5f00390207 | 8 | Beep buzzer(PA_15); |
omerbguclu | 0:3a5f00390207 | 9 | // Define your own keypad values |
omerbguclu | 0:3a5f00390207 | 10 | char Keytable[] = { '1', '2', '3', 'A', |
omerbguclu | 0:3a5f00390207 | 11 | '4', '5', '6', 'B', |
omerbguclu | 0:3a5f00390207 | 12 | '7', '8', '9', 'C', |
omerbguclu | 0:3a5f00390207 | 13 | '*', '0', '#', 'D' |
omerbguclu | 0:3a5f00390207 | 14 | }; |
omerbguclu | 0:3a5f00390207 | 15 | |
omerbguclu | 0:3a5f00390207 | 16 | uint32_t cbAfterInput(uint32_t index) { |
omerbguclu | 0:3a5f00390207 | 17 | //printf("Index:%d => Key:%c\n", key, Keytable[index]); |
omerbguclu | 0:3a5f00390207 | 18 | buzzer.beep(1500,0.1); |
omerbguclu | 0:3a5f00390207 | 19 | wait_ms(100); |
omerbguclu | 0:3a5f00390207 | 20 | buzzer.nobeep(); |
omerbguclu | 0:3a5f00390207 | 21 | lcd.cls(); |
omerbguclu | 0:3a5f00390207 | 22 | lcd.printf("Key:%c\n", Keytable[index]); |
omerbguclu | 0:3a5f00390207 | 23 | return 0; |
omerbguclu | 0:3a5f00390207 | 24 | } |
omerbguclu | 0:3a5f00390207 | 25 | |
omerbguclu | 0:3a5f00390207 | 26 | int main() { |
omerbguclu | 0:3a5f00390207 | 27 | Keypad keypad(PB_3, PD_7, PD_5, PD_6, PB_7, PB_6, PB_5, PB_4);//Row1-2-3-4 Col1-2-3-4 |
omerbguclu | 0:3a5f00390207 | 28 | keypad.CallAfterInput(&cbAfterInput); |
omerbguclu | 0:3a5f00390207 | 29 | keypad.Start(); |
omerbguclu | 0:3a5f00390207 | 30 | |
omerbguclu | 0:3a5f00390207 | 31 | while (1) { |
omerbguclu | 0:3a5f00390207 | 32 | wait_ms(100); |
omerbguclu | 0:3a5f00390207 | 33 | } |
omerbguclu | 0:3a5f00390207 | 34 | } |