#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key1=P3^4;
sbit led=P1^0;
uint i,j=0;
void main()
{
TMOD=0x01;*/初值自己改下,定时器T0工作在模式2方式*/
TH0=0x38;
TL0=0x38;
EA=1;
ET0=1;
while(1)
{
if(key1==0)
{
TR0=1;
while(!key1);
TR0=0;
j++;
if(j==5)
led=0;
if(j==10)
led=1;
}
}
}
|