|
#include
#define uint unsigned int
#define uchar unsigned char
void delay (uchar x)
{
uchar i,j; //¶¨Òå2¸öÎÞ·ûºÅÕûÐͱäÁ¿¡£
for(i=x;i>0;i--) //ͨ¹ýÈí·Â¹Û²ìµÃÖª
for(j=100;j>0;j--); //´Ë´¦ÑÓʱ1S
}
void main()
{
P0 = 0xff; // À¸ßP0£¬×¼±¸½ÓÊÕÊäÈë
P1 = 0x00; // P1ĬÈÏΪȫ0
P2 = 0x00; // P2ĬÈÏΪȫ0
while(1)
{switch(P0)
{case 1 : {P0=0xfe;P1=0x01;
delay(2000);
while(1)
{P1=0x01;
delay(500) ;
P1=0x00;
delay(500) ;
} ;
break;}
case 2 : {P0=0xfd;P1=0x02;
delay(1000);
while(1)
{P1=0x02;
delay(500);
P1=0x00;
delay(100) ;
} ;
break;}
case 3 : {P0=0xfb;P1=0x04;
delay(1000);
while(1)
{P1=0x04;
delay(100);
P1=0x00;
delay(100) ;
};
break;}
case 4: {P0=0xf7;P1=0x08;
delay(1000);
while(1)
{P1=0x08;
delay(100);
P1=0x00;
delay(100);
} ;
break;}
case 0xef: {P1=0x10;
delay(1000);
while(1)
{P1=0x10;;
delay(100);
P1=0x00;
delay(100);
};
break;}
case 0xea: {P1=0x20;
delay(1000);
while(1)
{ P1=0x20;
delay(100);
P1=0;
delay(100);
} ;
break;}
case 0xbf: {P1=0x40;
delay(1000);
while(P1)
{P1=0x40;
delay(100);
P1=0x00;
delay(100);
};
break;}
case 0x7f: {P1=0x80;
delay(1000);
while(1)
{P1=0x80;
delay(100);
P1=0x00;
delay(100);
};
break;}
default: {
P1=0x00;
}
}
}
}
|
|