给你个框子,剩下的自己再改改。
void delay()
{
for(int i=0;i<100;i++)
for(int j=0;j<200;j++);
}
void delay10()
{
for(int i=0;i<10;i++)
for(int j=0;j<10;j++);
}
void main(void)
{
unsigned char i,j,k,l;
unsigned char LED1[5]={0x81,0x42,0x24,0x18,0};
unsigned char LED2[5]={0x18,0x24,0x42,0x81,0};
unsigned char LED3[9]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0};
unsigned char LED4[9]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0};
// Write your code here
P1=0;
while (1)
{
if(P3_0==0)
{
delay10();
if(P3_0==0)
{
for(i=0;i<9;i++)
{
P1=LED3;
delay();
}
while(P3_0==0);
}
}
if(P3_1==0)
{
delay10();
if(P3_1==0)
{
for(j=0;j<9;j++)
{
P1=LED4[j];
delay();
}
while(P3_1==0);
}
}
if(P3_2==0)
{
delay10();
if(P3_2==0)
{
for(k=0;k<5;k++)
{
P1=LED1[k];
delay();
}
while(P3_2==0);
}
}
if(P3_3==0)
{
delay10();
if(P3_3==0)
{
for(l=0;l<5;l++)
{
P1=LED2[l];
delay();
}
while(P3_3==0);
}
}
}
}
|