Teclado matricial con sonido
Dependencies: FPointer TextLCD keypad mbed
Fork of Tarea3_Teclado by
main.cpp@1:4fa754f4522d, 2014-04-23 (annotated)
- Committer:
- Jepalacioh
- Date:
- Wed Apr 23 15:05:20 2014 +0000
- Revision:
- 1:4fa754f4522d
- Parent:
- 0:01487f2574c6
Tarea 3 Procesadores UNAL semestre 2014-1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jepalacioh | 1:4fa754f4522d | 1 | //Julian Esteban Palacio Hernandez |
Jepalacioh | 1:4fa754f4522d | 2 | //Andres Mauricio Gomez Arevalo |
Jesse | 0:01487f2574c6 | 3 | |
Jesse | 0:01487f2574c6 | 4 | |
Jesse | 0:01487f2574c6 | 5 | #include "mbed.h" |
Jepalacioh | 1:4fa754f4522d | 6 | #include "keypad.h" //Librería de manejo de Teclado |
Jepalacioh | 1:4fa754f4522d | 7 | #include "TextLCD.h"//Librería de LCD |
Jesse | 0:01487f2574c6 | 8 | |
Jesse | 0:01487f2574c6 | 9 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 |
Jesse | 0:01487f2574c6 | 10 | DigitalOut Sonido(PTB8); |
Jesse | 0:01487f2574c6 | 11 | |
Jesse | 0:01487f2574c6 | 12 | |
Jesse | 0:01487f2574c6 | 13 | |
Jesse | 0:01487f2574c6 | 14 | //Defino salida a Pwm |
Jesse | 0:01487f2574c6 | 15 | PwmOut Pwm(PTA5); |
Jesse | 0:01487f2574c6 | 16 | |
Jesse | 0:01487f2574c6 | 17 | //Definicion de Variables |
Jesse | 0:01487f2574c6 | 18 | |
Jesse | 0:01487f2574c6 | 19 | float pp=0.001; |
Jesse | 0:01487f2574c6 | 20 | float Dd=0.1; |
Jesse | 0:01487f2574c6 | 21 | char key,keyy; |
Jesse | 0:01487f2574c6 | 22 | int C1=0x0F; |
Jesse | 0:01487f2574c6 | 23 | |
Jesse | 0:01487f2574c6 | 24 | // Define your own keypad values |
Jesse | 0:01487f2574c6 | 25 | char Keytable[] = { '1', '2', '3', 'A', |
Jesse | 0:01487f2574c6 | 26 | '4', '5', '6', 'B', |
Jesse | 0:01487f2574c6 | 27 | '7', '8', '9', 'C', |
Jesse | 0:01487f2574c6 | 28 | '*', '0', '#', 'D' |
Jesse | 0:01487f2574c6 | 29 | }; |
Jesse | 0:01487f2574c6 | 30 | |
Jesse | 0:01487f2574c6 | 31 | |
Jesse | 0:01487f2574c6 | 32 | //Funcion de PWM |
Jesse | 0:01487f2574c6 | 33 | int PWMmodule(float pp,float Dd) |
Jesse | 0:01487f2574c6 | 34 | { |
Jesse | 0:01487f2574c6 | 35 | Pwm.period(pp); |
Jesse | 0:01487f2574c6 | 36 | Pwm.write(Dd); |
Jesse | 0:01487f2574c6 | 37 | wait(0.1); |
Jesse | 0:01487f2574c6 | 38 | Pwm.write(0); |
Jesse | 0:01487f2574c6 | 39 | return 0; |
Jesse | 0:01487f2574c6 | 40 | } |
Jesse | 0:01487f2574c6 | 41 | |
Jesse | 0:01487f2574c6 | 42 | uint32_t cbAfterInput(uint32_t Key) |
Jesse | 0:01487f2574c6 | 43 | { |
Jesse | 0:01487f2574c6 | 44 | |
Jesse | 0:01487f2574c6 | 45 | PWMmodule(pp,Dd); |
Jesse | 0:01487f2574c6 | 46 | key=Key; |
Jesse | 0:01487f2574c6 | 47 | lcd.locate(0,0); |
Jesse | 0:01487f2574c6 | 48 | lcd.printf("%c",Keytable[key]); |
Jesse | 0:01487f2574c6 | 49 | |
Jesse | 0:01487f2574c6 | 50 | return 0; |
Jesse | 0:01487f2574c6 | 51 | } |
Jesse | 0:01487f2574c6 | 52 | |
Jesse | 0:01487f2574c6 | 53 | int main() |
Jesse | 0:01487f2574c6 | 54 | |
Jesse | 0:01487f2574c6 | 55 | { |
Jesse | 0:01487f2574c6 | 56 | //Configuracion de Pines: |
Jesse | 0:01487f2574c6 | 57 | //Filas van a Resistencia que van a tierra, y tambien a los puertos |
Jesse | 0:01487f2574c6 | 58 | //Columnas van directamente a los pines de la tarjeta. |
Jesse | 0:01487f2574c6 | 59 | |
Jesse | 0:01487f2574c6 | 60 | // r0 r1 r2 r3 c0 c1 c2 c3 |
Jesse | 0:01487f2574c6 | 61 | Keypad keypad(PTA2,PTD4,PTD3,PTD1,PTD2,PTD0,PTD5,PTA13); |
Jesse | 0:01487f2574c6 | 62 | //keypad.attach(&cbAfterInput); |
Jesse | 0:01487f2574c6 | 63 | keypad.CallAfterInput(&cbAfterInput); |
Jesse | 0:01487f2574c6 | 64 | keypad.Start(); // energiza las columnas C0-C3 Del Keypad |
Jesse | 0:01487f2574c6 | 65 | |
Jesse | 0:01487f2574c6 | 66 | |
Jesse | 0:01487f2574c6 | 67 | while (1) |
Jesse | 0:01487f2574c6 | 68 | { |
Jesse | 0:01487f2574c6 | 69 | |
Jesse | 0:01487f2574c6 | 70 | } |
Jesse | 0:01487f2574c6 | 71 | } |
Jesse | 0:01487f2574c6 | 72 |