ZMRGHY 发表于 2021-9-6 19:24 厉害了大师,不用了,我自己想想把它搞定 |
| 小意思,用不再写一个从中间向俩端的流水灯呀 |
简化后的。。。。温故知新,,,温习一下位移运算。。。。 |
没什么问题呀 |
|
|
|
#include <reg52.h> void DelayMs(unsigned int n); /*------------------*/ void main (void) { unsigned char temp =0x7E; unsigned int temph , templ; while(1) { P1=temp; DelayMs(2000); if(temp==0xff) temp=0x7E; { temph=temp & 0xf0,templ=temp & 0x0f; temph=(temph >> 1)|0x80, templ=(templ << 1)|0x01; temp=temph|templ;} } } /*---------------------*/ void DelayMs(unsigned int n) { unsigned int i,j; for(i=0;i<n;i++) { for(j=110;j>0;j--); } } |