#include<reg51.h>
#include<intrins.h>
#define GPIO_LED P2
sbit k1=P3^1;
void Delay10ms(unsigned int c);
void main(void)
{
unsigned int i;
bit f;
f=0;
GPIO_LED=0xfe;
while(1)
{
if(k1==0)
{
Delay10ms(1);
if(k1==0)
{
f=~f;
while((i<50)&&(k1==0))
{
Delay10ms(1);
i++;
}
i=0;
}
}
if (f==1)
{
GPIO_LED=_crol_(GPIO_LED,1);
Delay10ms(30);
}
}
}
void Delay10ms(unsigned int c)
{
unsigned char a,b;
for(c;c>0;c--)
for(b=38;b>0;b--)
for(a=130;a>0;a--);
}
|