brian barreto / Mbed 2 deprecated comunicacionserial

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 
00005 int filas[5]={0,1,2,4,8};
00006 char tecla[6][6];
00007 int lectura;
00008 
00009 Serial pc(USBTX,USBRX);
00010 
00011 int main()
00012 {
00013     TextLCD lcd(D10, D11, D12, D13, D14, D15, TextLCD::LCD16x2);
00014     BusOut salida(D2,D3,D4,D5);
00015     BusIn entrada(D6,D7,D8,D9);
00016 
00017 //primera fila    
00018 tecla[1][1]='1'; 
00019 tecla[1][2]='2'; 
00020 tecla[1][3]='3'; 
00021 tecla[1][4]='A';
00022 
00023 //segunda fila
00024 tecla[2][1]='4'; 
00025 tecla[2][2]='5'; 
00026 tecla[2][3]='6'; 
00027 tecla[2][4]='B';
00028 
00029 //tercer fila
00030 tecla[3][1]='7'; 
00031 tecla[3][2]='8'; 
00032 tecla[3][3]='9'; 
00033 tecla[3][4]='C';
00034 
00035 //cuarta fila
00036 tecla[4][1]='*'; 
00037 tecla[4][2]='0'; 
00038 tecla[4][3]='#'; 
00039 tecla[4][4]='D';
00040 
00041 while(1)
00042 {
00043     for(int o=1;o<5;o++)
00044     {
00045         
00046         salida=filas[o];
00047         lectura=entrada.read();
00048         
00049         if(lectura==1)
00050         {lectura=1;}
00051         if(lectura==2)
00052         {lectura=2;} 
00053         if(lectura==4)
00054         {lectura=3;} 
00055         if(lectura==8)
00056         {lectura=4;}
00057         
00058         if(lectura!=0)
00059         {
00060        lcd.locate(0,0);
00061         lcd.printf("IN: %c ",tecla[o][lectura]);
00062         pc.printf("IN: %c ",tecla[o][lectura]);
00063         
00064         
00065         wait(0.2);
00066 }
00067 }
00068 }
00069 }