#include <reg52.h>
#include <intrins.h>
char i;
sbit led1=P2^0; //指示灯0
sbit led2=P2^1; //指示灯1
sbit led3=P2^2; //指示灯3
sbit led7=P2^7; //指示灯3
//void delay(unsigned char k)
//{
// unsigned int y,z;
// for(y=k;y>0;y--)
// {
// for(z=110;z>0;z--);
//
// }
//}
void main (void)
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
REN=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
while(1)
{
i=SBUF;
RI=0;
switch(i)
{
case '1': led1=0; break;
case '2': led2=0; break;
case 3: led3=0; break;
case 4: led7=0; break;
case 5: led1=1,led2=1,led3=1,led7=1; break;
}
//if (i==0x02){led1=0;}
//if (i==0x08){led2=0;}
//if (i==0x01){led3=0;}
//if (i==0x03){led7=0;}
//if (i==0x05){led1=1;led2=1;led3=1;led7=1;}
//delay(1000);
//SBUF=i;
}
}
void Serial(void) interrupt 4
{
i = SBUF;
RI = 0; //读标志清零
SBUF = i; //将内容返回到手机端,可在手机查看发送的内容
while(!TI);
TI = 0; //写标志清零
}
//为什么手机发送ASCII码灯不亮
|