You are on page 1of 2

CODIGO PARA CALCULAR EL AREA DE UN TRIANGULO

sbit LCD_RS at RB4_bit;


sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
unsigned char BaseT,AlturaT,AreaT;
char ValStr[4];
char keypadPort at PORTD;
void main() {
ADCON1=15;
CMCON=7;
INTCON=0;
Keypad_Init();
Lcd_Init();
bucle:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Area del");
Lcd_Out(2,6,"Triangulo");
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
Lcd_Out(1,1,"Base=");
do{
BaseT=Keypad_Key_Click();
}while(BaseT==0);
ByteToStr(BaseT,ValStr);
Lcd_Out_Cp(ValStr);
Delay_ms(800);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Altura=");
do{
AlturaT=Keypad_Key_Click();
}while(AlturaT==0);
ByteToStr(AlturaT,ValStr);
Lcd_Out_Cp(ValStr);
Delay_ms(800);
AreaT=(BaseT*AlturaT)/2;
ByteToStr(AreaT,ValStr);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,1,"Area=");
Lcd_Out_Cp(ValStr);
Delay_ms(2000);
goto bucle;
}
REFERENCIA DE LA INVESTIGACION

TECLADO QWERTY

PROTOCOLOS

You might also like