#include <reg52.h>
sbit key=P1^0;
sbit out=P1^1;
sbit out2=P1^2;
void main()
{
bit key_psat,FLAG,ks;
unsigned long count;
out=0;
while(1)
{
ks=key;
if(ks==1 && key_psat==0)
{
out2=!out2;
if(FLAG==1)
{
if(count<20000)
{
out=!out;
}
FLAG=0;
count=0;
}
else
{
FLAG=1;
}
}
key_psat=ks;
if(FLAG==1 && count<20000)
{
count++;
if(count>=20000)
{
count=0;
FLAG=0;
}
}
}
}
你说我是不是有点闲
|