0% found this document useful (0 votes)
20 views2 pages

Teclado 2

Uploaded by

Joel Camacho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Teclado 2

Uploaded by

Joel Camacho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// LCD module connections

sbit LCD_RS at RB0_bit;


sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;


sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections
// Keypad module connections
char keypadPort at PORTC;
// End Keypad module connections

char tecla;
char teclado(){
char valor=0;
valor=Keypad_Key_press();
if(valor !=0){
switch(valor){
case 1:valor='7';break;
case 2:valor='8';break;
case 3:valor='9';break;
case 4:valor='/';break;
case 5:valor='5';break;
case 6:valor='5';break;
case 7:valor='6';break;
case 8:valor='*';break;
case 9:valor='1';break;
case 10:valor='2';break;
case 11:valor='3';break;
case 12:valor='-';break;
case 13:valor='c';break;
case 14:valor='0';break;
case 15:valor='=';break;
case 16:valor='+';break;
}
return valor;
}
}
int c1=0;
int a1=0;
int a2=0;
int producto;
int s1=0;
int s2=0;
int So1=0;
int So2=0;
int D1=0;
int D2=0;
void main() {
Lcd_Init(); //Initialize LCD
Lcd_Cmd(_LCD_CLEAR); //Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); //Cursor off
keypad_init();
while(1){
if(a1==0){
Lcd_out(1,1,"Esperando..");
}
tecla=teclado();
if(tecla=='/'){
a1=1;
c1++;
delay_ms(250);
}
switch (c1){
case 1:lcd_out(1,1,"1. Snak ");producto=1;break;
case 2:lcd_out(1,1,"2. Soda ");producto=2;break;
case 3:lcd_out(1,1,"3. Dulce ");producto=3;break;
case 4:c1=1;break;
}
if(tecla=='*'&&producto==1){
lcd_out(2,1,"1.S-1 2.S-2");
}
if(tecla=='*'&&producto==2){
lcd_out(2,1,"1.So-1 2.So-2");
}
if(tecla=='*'&&producto==3){
lcd_out(2,1,"1.D-1 2.D-2 ");
}
if((tecla=='1')&&(producto==1||producto==2||producto==3)){
lcd_out(2,1," ");
a2=1;
}
if((tecla=='2')&&(producto==1||producto==2||producto==3)){
lcd_out(2,8," ");
a2=2;
}
if(a2==1&&tecla=='-'){
s1++;
delay_ms(250);
}
if(a2==1&&tecla=='-'){
s1--;
delay_ms(250);
}
if(s1>0&&s1<5){
lcd_out(1,12,"C=");
lcd_chr(1,14,48+s1);
}
}
}

You might also like