#include<reg51.h>
sbit ceng1=P2^0;
sbit ceng2=P2^1;
sbit ceng3=P2^2;
sbit ceng4=P2^3;
sbit p10=P1^0;
sbit p11=P1^1;
sbit p12=P1^2;
sbit p13=P1^3;
sbit p14=P1^4;
sbit p15=P1^5;
sbit p16=P1^6;
sbit p17=P1^7;
sbit p30=P3^0;
sbit p31=P3^1;
sbit p32=P3^2;
sbit p33=P3^3;
sbit p34=P3^4;
sbit p35=P3^5;
sbit p36=P3^6;
sbit p37=P3^7;
void delay(unsigned char i);
void main()
{
P1=0x00;
P3=0x00;
ceng1=1;
ceng2=1;
ceng3=1;
ceng4=0;
while(1)
{
p34=1;
delay(2);
p35=1;
delay(2);
p36=1;
delay(2);
p37=1;
delay(2);
p33=1;
delay(2);
p17=1;
delay(2);
p13=1;
delay(2);
p12=1;
delay(2);
p11=1;
delay(2);
p10=1;
delay(2);
p14=1;
delay(2);
p30=1;
delay(2);
p34=1;
delay(2);
//第一層運行完
ceng1=1;
ceng2=1;
ceng3=0;
ceng4=0;
p34=1;
delay(2);
p35=1;
delay(2);
p36=1;
delay(2);
p37=1;
delay(2);
p33=1;
delay(2);
p17=1;
delay(2);
p13=1;
delay(2);
p12=1;
delay(2);
p11=1;
delay(2);
p10=1;
delay(2);
p14=1;
delay(2);
p30=1;
delay(2);
p34=1;
delay(2);
}
}
void delay(unsigned char i)
{
unsigned int i1,a;
for(i1=i;i1>0;i1--)
{
for(a=5000;a>0;a--);
}
}
|