![]() |
谢谢songxia8013提醒,现在修改如下: #include <reg2051.h> const unsigned char P1_arry[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; const unsigned char P3_arry[8]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07}; void delay(unsigned int cnt) { unsigned int i; while(cnt--) { for(i = 0;i < 227;i++); } } void main() { unsigned char i, j; while(1) { for(i=0;i<8;i++) { P1 = P1_arry[ i]; for(j=0;j<8;j++) { P3 = P3_arry[j]; delay(200); } } } } |
这程序写的太长了,可以优化下。搞个数组,然后for循环调用,很短的程序应该就能搞定。 |
看到楼主的代码,让我陷入深深的回忆当中——当年写汇编代码应该就是这样的风格,你是不是还没扭转过来![]() ![]() |