LDC_TECLADO_MATRICIAL

Dependencies:   TextLCD mbed

main.cpp

Committer:
grupo3
Date:
2017-09-16
Revision:
0:5ea4be70fe49

File content as of revision 0:5ea4be70fe49:

#include "mbed.h"
#include "TextLCD.h"
#include "keypad.h"
Serial pc(USBTX,USBRX);
TextLCD lcd(D10,D11,D12,D13,D14,D15);

int filas[5]= {0,1,2,4,8};
int lec;
char boton[5][5];
int main()
{
    BusOut sal(D2,D3,D4,D5);
    BusIn entrada(D6,D7,D8,D9);

    boton[1][1]='1';
    boton[2][1]='4';
    boton[3][1]='7';
    boton[4][1]='*';
    boton[1][2]='2';
    boton[2][2]='5';
    boton[3][2]='8';
    boton[4][2]='0';
    boton[1][3]='3';
    boton[2][3]='6';
    boton[3][3]='9';
    boton[4][3]='!';
    boton[1][4]='h';
    boton[2][4]='e';
    boton[3][4]='l';
    boton[4][4]='p';

    int count=0;
    int count1=20;


    while(1) {

        for(int i=1; i<5; i++) {

            sal=filas[i];
            lec=entrada.read();
            if(lec==4) {
                lec=3;
            }
            if(lec==8) {
                lec=4;
            }
            if(lec!=0) {
                if(count<=15) {
                    lcd.locate(count,0);
                    lcd.printf("%c",boton[i][lec]);
                    wait(0.2);
                    count++;
                }
                if(count==15) {
                    count1=0;
                    lcd.locate(count1,1);
                    
                }
                if(count1<=15) {
                    lcd.printf("%c",boton[i][lec]);
                    count1++;
                    if(count1>15) {
                        lcd.cls();
                        count=0;
                    }
                }
            }
        }
    }
}