#include<stc12c5a60s2.h>
#include<stdio.h>
sbit P3_7=P3^7;
sbit P2_6=P2^6;
sbit P3_6=P3^6;
void uart(void)
{
SCON=0x40;
REN=1;
TMOD=0x20;
TH1=0xfd;
TL1=0Xfd;
TI=1;
TR1=1;
}
int R_CHAR()
{ int NUM;
while(!RI);
NUM=SBUF;
return NUM;
}
main()
{
int sw_code;
uart();
P2_6=0;
P3_6=0;
P3_7=1;
printf("Please control LED\n");
while(1)
{
sw_code=R_CHAR();
switch(sw_code)
{
case 0:
{
P0=0xfe;
printf("LED0 is bright\n");
break;
}
case 1:
{
P0=0xfd;
printf("LED1 is bright\n");
break;
}
case 2:
{
P2=0xfb;
printf("LED2 is bright\n");
break;
}
case 3:
{
P0=0xf7;
printf("LED3 is bright\n");
break;
}
case 4:
{
P1=0xef;
printf("LED4 is bright\n");
break;
}
case 5:
{
P0=0xdf;
printf("LED5 is bright\n");
break;
}
case 6:
{
P0=0xbf;
printf("LED6 is bright\n");
break;
}
case 7:
{
P0=0x7f;
printf("LED7 is bright\n");
break;
}
default:printf("input the error\n");
}
}
}