#include <reg51.h>
#define TIME 1200
void main()
{
unsigned char i,W;
P1=0xff;
while(1)
{
if(K==0)
{
delay (1200);
if(K1==0)
{ W=0x01;
for(i=0;i<8;i++)
{
P1=~W;
delay(10000);
W<<=1;
}
}
}
else P1=0x00;
}
}
sbit K1=P0^0;
sbit K2=P0^1;
sbit K3=P0^2;
sbit K4=P0^3;
if(K1==0)
{
delay(TIME);
if 1:P1=0x00;
}
else if(K2==0)
{
delay(TIME);
if 2:P1==0x55;
}
else if(K3==0)
{
delay(TIME);
if 3:P1==0x0f;
}
else if(K4==0)
{
delay(TIME);
if 4:P1==0xf0;
}
|