标题: 求帮忙解释一下这个单片机程序 [打印本页]

作者: yb1314Y    时间: 2019-6-23 20:39
标题: 求帮忙解释一下这个单片机程序
  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int

  4. uchar code Pattern_P0[]=
  5. {
  6.          0xfc,0xf9,0xf3,0xe7,0xcf,0x9f
  7. };
  8. uchar code Pattern_P2[]=
  9. {
  10.          0xf5,0xf6,0xfe,0x54,0x56,0x76,0xd7,0x49,0xa9,0xe4,0xc6
  11. };

  12. void DelayMS(uint x)
  13. {
  14.          uchar t;
  15.         while(x--)
  16.         {
  17.                  for(t=120;t>0;t--);
  18.         }
  19. }

  20. void main()
  21. {
  22.          uchar i;
  23.         while(1)
  24.         {
  25.                  for(i=136;i>0;i--)
  26.                 {
  27.                          P0=Pattern_P0[i];
  28.                         P2=Pattern_P2[i];
  29.                         DelayMS(150);
  30.                 }        
  31.         }
  32. }
复制代码

作者: xianfajushi    时间: 2019-6-24 05:07
这个程序没什么特别的,就是循环送数组的数据到端口,不过单循环的值已经超过数组的量了。
作者: charles11    时间: 2019-6-24 07:34
其实那个for语句看的不是很懂,数组里面个数显然没有136个,为什么要循环这么多次?
作者: yb1314Y    时间: 2019-6-24 11:46
那个大神帮我全部都说一下




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1