Teclado y LCD 2x16
Dependencies: TextLCD keypad mbed
test1.cpp
- Committer:
- franni
- Date:
- 2017-04-24
- Revision:
- 0:3a2f24d6afbd
- Child:
- 1:faf520c1baac
File content as of revision 0:3a2f24d6afbd:
#include "mbed.h" #include "TextLCD.h" #include "Keypad.h" //Serial PC(USBTX, USBRX); // Define your own keypad values char Keytable[] = { '1', '2', '3', 'A', // r0 '4', '5', '6', 'B', // r1 '7', '8', '9', 'C', // r2 '*', '0', '#', 'D' // r3 }; // c0 c1 c2 c3 int32_t Index = -1; TextLCD lcd(PTE20,PTE21,PTE22,PTE23,PTE29,PTE30, TextLCD::LCD16x2); // Rs, E, d4, d5, d6, d7 uint32_t cbAfterInput(uint32_t _index) { Index = _index; return 0; } int main() { lcd.printf("Mi primer tecladito...\r\n"); wait(1); lcd.cls(); lcd.locate(0,0); // r0 r1 r2 r3 c0 c1 c2 c3 Keypad keypad(PTC9, PTC8, PTA5, PTA4, PTA12, PTD4, PTA1, PTA2); keypad.attach(&cbAfterInput); keypad.start(); // energiza columnas c0-c3 del keypad while (1) { __wfi(); if (Index > -1) { lcd.printf("Key:%c\r\n",Keytable[Index]); Index = -1; } wait(0.5); } }