a

Dependencies:   mbed TextLCD Keypad

main.cpp

Committer:
20172573073
Date:
2020-08-24
Revision:
0:0b651cdc4e79

File content as of revision 0:0b651cdc4e79:

#include "mbed.h"
#include "TextLCD.h"
#include "Keypad.h"
Keypad kpad(PTC4, PTC0, PTB19, PTB18, PTC11, PTC10, PTC7, PTC6);
TextLCD lcd(D0,D1,D2,D3,D4,D5, TextLCD::LCD16x2 );

char key ;
int x =0;
int y =0;
int i,j,k;
Ticker teclado;
void tec()
{
    key = kpad.ReadKey();
}
void keysito()
{
    switch(key) {
        case '1':
            lcd.printf("1");
            x=1;
            y=y+1;
            break;

        case '2':
            lcd.printf("2");
            x=2;
            y=y+1;
            break;

        case '3':
            lcd.printf("3");
            x=3;
            y=y+1;
            break;
        case '4':
            lcd.printf("4");
            x=4;
            y=y+1;
            break;

        case '5':
            lcd.printf("5");
            x=5;
            y=y+1;
            break;

        case '6':
            lcd.printf("6");
            x=6;
            y=y+1;
            break;
        case '7':
            lcd.printf("7");
            x=7;
            y=y+1;
            break;

        case '8':
            lcd.printf("8");
            x=8;
            y=y+1;
            break;

        case '9':
            lcd.printf("9");
            x=0;
            y=y+1;
            break;
            
        case '0':
            lcd.printf("0");
            x=0;
            y=y+1;
            break;


    }

    wait(0.5);

}
void filas()
{
    lcd.locate(0,0);
    lcd.printf("# filas < 16");
    lcd.locate(0,1);
    keysito();
    
}

void columnas()
{
    lcd.locate(0,0);
    lcd.printf("# columnas < 2");
    lcd.locate(0,1);
    keysito();
}
void asterisco()
{
    lcd.locate(0,0);
    lcd.printf("# asteriscos");
    lcd.locate(0,1);
    keysito();
}
int main ()
{

    //teclado.attach(&tec,0.01);

    while(1) {
        tec();
        if(y == 0) {
            lcd.cls();
            filas();
            i=x;
            x=0;
            wait(1.5);
        }tec();
        if(y == 1) {
            lcd.cls();
            columnas();
            j=x;
            x=0;
            wait(1.5);
        }tec();
        if(y == 2) {
            lcd.cls();
            asterisco();
            k=x;
            x=0;
            wait(1.5);
        if( y > 2){
        lcd.cls();
        lcd.locate(i,j);
        int a=1;
        while(k >= a){
            lcd.printf("*");
            a=a+1;
            }
            }
        }
    }
}