问答

汇集网友智慧,解决技术难题

21ic问答首页 - TAG - 嵌入式stc89c51
  • 点亮流水灯只能用延时函数吗?

    本人用delay函数可以成功完成流水灯,但是用for却失败了,问了C语言老师,他也不清楚,请问该如何修改呢?谢谢。/*成功*/。 #include #include #define uint unsigned int #define uchar unsigned char uchar temp; void delay(); void main() { temp=0xfe; P1=temp; while(1) { temp=_crol_(temp,1); delay(); P1=temp; } } void delay() { uint x,y; for(x=1000;x>0;x--) for(y=200;y>0;y--); } /*失败*/ #include #include sbit p1_1=P1^0; #define uchar unsigned char//宏定义 #define uint2 unsigned int uchar temp;//字符型,要8位的,uchar是8位的 unsigned int a; void delay(uint2); void main() { temp=0xfe; p1_1=temp; while(1) { temp=_crol_(temp,1); uint2 x,y; a=50000; p1_1=temp; while(a--); for(x=130;x>0;x--) for(y=452;y>0;y--); a=50000; p1_1=temp; while(a--); for(x=130;x>0;x--) for(y=452;y>0;y--); } }

    嵌入式stc89c51 函数 流水灯 TE FOR unsigned

    26436浏览量 13回复量 关注量