#include "reg52.h"
typedef unsigned int u16;
typedef unsigned char u8;
sbit k1 =P1^0; //定义按键输入端口
sbit led1=P1^4; //定义led输出端口
sbit led2=P1^3;
sbit led3=P1^2;
sbit led4=P1^1;
sbit led5=P0^5;
sbit led6=P0^4;
sbit led7=P2^7;
sbit led8=P2^6;
/*------------------------------------------------
yanshi
------------------------------------------------*/
void delay500ms(void) //误差 0us
{
unsigned char a,b,c;
for(c=205;c>0;c--)
for(b=116;b>0;b--)
for(a=9;a>0;a--);
}
void keypros()
{
if(k1==0)
{
if(k1==0)
{
led1=0;
led2=0;
delay500ms();
led3=0;
led4=0;
delay500ms();
led5=0;
led6=0;
delay500ms();
led7=0;
led8=0;
}
else
{
led1=1;
led2=1;
led3=1;
led4=1;
led5=1;
led6=1;
led7=1;
led8=1;
}
}
}
|