#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit led1=P1^0;
sbit led2=P1^1;
sbit led3=P1^2;
sbit led4=P1^3;
sbit led5=P1^4;
uchar a,flag=0;
void lanya_init();
void main()
{
lanya_init();
while (1)
{
if(flag==1)
{
switch (a)
{
case 'c':P1=1;break;
case '2':led2=1;break;
case '3':led3=1;break;
case '4':led4=1;break;
case '5':led5=1;break;
default: break;
}
}
flag=0;
P1=0X00;
}
}
void lanya_init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SM0=0;
SM1=1;
REN=1;
ES=1;
EA=1;
}
void ser() interrupt 4
{
RI=0;
a=SBUF;
flag=1;
}
|