LCD con teclado matricial

Fork of TextLCD by Simon Ford

main.cpp

Committer:
nikor97r
Date:
2017-09-23
Revision:
9:db3c260474f6

File content as of revision 9:db3c260474f6:

#include "mbed.h"
#include "TextLCD.h"
Serial pc(USBTX,USBRX);
char boton[5][5];
TextLCD lcd(D2,D3,D4,D5,D6,D7);
int main() 
{
    
    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]='o';
    boton[3][4]='l';
    boton[4][4]='a';
    while(1)
    {
    int filas[5] = {0,1,2,4,8};
    int lectura;
    int pos = 0;
    BusOut sal(D8,D9,D10,D11);
    BusIn ent(D12,D13,D14,D15);
    while(1)
    {
        for(int i = 0; i < 5; i++)
        {
            sal=filas[i];
            lectura = ent.read();
            
            if (lectura == 4)
            {
                lectura = 3;
            }
            if (lectura == 8)
            {
                lectura = 4;
            }
            if (lectura != 0)
            {
                if (pos == 15)
                {
                    lcd.cls();
                    pos =0;
                }
                else{
                lcd.locate(pos,0);
                lcd.printf("%c",boton[i][lectura]); 
                pc.printf("%c",boton[i][lectura]);
                wait(0.5);
                pos++;
                }
                
            }
            
        }
    
    }
    }
}