标题:
while循环中的语句只运行了一次后停止,死循环为什么会这样?
[打印本页]
作者:
董亚伟
时间:
2014-10-21 23:47
标题:
while循环中的语句只运行了一次后停止,死循环为什么会这样?
#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--);
}
}
作者:
T29
时间:
2014-10-22 12:02
你的第一层是不是要把
//第一层运行完
ceng1=1;
ceng2=1;
ceng3=0;
ceng4=0;
这段也包括经去呀
作者:
T29
时间:
2014-10-22 12:03
T29 发表于 2014-10-22 12:02
你的第一层是不是要把
//第一层运行完
ceng1=1;
错了,是
ceng1=1;
ceng2=1;
ceng3=1;
ceng4=0;
这段
作者:
hkccd
时间:
2014-10-22 12:38
历害,又学习了,mark一下
作者:
hjlost
时间:
2014-10-24 14:04
掘墓高手,专挖古墓,一挖一个坑,坑坑见墓。。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1