标题: Proteus学习单片机2-流水灯 [打印本页]

作者: hemoparrot    时间: 2018-3-30 16:02
标题: Proteus学习单片机2-流水灯
电路图:

代码:
  1. #include <reg52.h>
  2. #include <intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int

  5. //延时
  6. void DelayMS(uint x)
  7. {
  8.         uchar i;
  9.         while(x--)
  10.         {
  11.                 for(i=0;i<120;i++);
  12.         }
  13. }
  14. void main()
  15. {
  16.         P0=0xfe;
  17.         while(1)
  18.         {
  19.                 P0=_crol_(P0,1);
  20.                 DelayMS(150);
  21.         }
  22. }
复制代码







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