#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define led P1
sbit k4=P3^6;
uchar a;
bit stop=1;
uchar led1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void delay(uint xms)
{
uchar i,j;
for(i=xms;i>0;i--)
for(j=112;j>0;j--);
}
void ledi()
{
uchar a;
while(1)
{
for(a=0;a<8;a++)
{
led=~(0x01<<a);
delay(2500);
}
}
}
void stop_led()
{
led=0xff;
}
void key4()
{
if(k4==0)
{
delay(10);
if(k4==0)
{
while(k4==0);
{
if(stop)
ledi();
else
stop_led();
stop=~stop;
}
}
}
}
void main()
{
while(1)
{
key4();
}
}
|