void main(){
char str[6]="verde";
char str1[6]="azuul";
char str2[6]="rojos";
char str3[6]="amari";
char cad[6];
ANSEL=ANSELH=0x00;
TRISB=0x00;
Uart1_Init(9600);
osccon=0x77;
while(1) {
if (Uart1_Data_Ready()) {
Uart1_Read_Text(cad,"\.",255);
Uart1_Write_text(cad);
// verde
if(!strcmp(str,cad))
{
Uart1_Write(13);
PORTB=0B00000001;
delay_ms(100);
cad[0]=cad[1]=cad[2]=cad[3]=cad[4]=cad[5]=" ";
} // azuul
else if(!strcmp(str1,cad))
{
Uart1_Write(13);
PORTB=0B00000010;
delay_ms(100);
cad[0]=cad[1]=cad[2]=cad[3]=cad[4]=cad[5]=" ";
} // rojos
else if(!strcmp(str2,cad))
{
Uart1_Write(13);
PORTB=0B00000100;
delay_ms(100);
cad[0]=cad[1]=cad[2]=cad[3]=cad[4]=cad[5]=" ";
} //amari
else if(!strcmp(str3,cad))
{
Uart1_Write(13);
PORTB=0B00001000;
delay_ms(100);
cad[0]=cad[1]=cad[2]=cad[3]=cad[4]=cad[5]=" ";
}
else {
//Uart1_Write_text(" Falso ");
Uart1_Write(13);
PORTB=0B00010000;
delay_ms(100);
cad[0]=cad[1]=cad[2]=cad[3]=cad[4]=cad[5]=" ";
}
} //if
}
}
Comentarios