标题: 单片机流水灯控制器设计仿真 [打印本页]

作者: 123周海    时间: 2017-5-23 21:28
标题: 单片机流水灯控制器设计仿真
单片机流水灯控制器设计仿真


单片机代码:
  1. #include <REGX52.H>

  2. void Delay1ms(unsigned int count)
  3. {
  4.         unsigned int i,j;
  5.         for(i=0;i<count;i++)
  6.         for(j=0;j<120;j++);
  7. }

  8. main()
  9. {
  10.         unsigned char LEDIndex = 0;
  11.         bit LEDDirection = 1;

  12.         while(1)
  13.         {
  14.                 if(LEDDirection)
  15.                         P1 = ~(0x01<<LEDIndex);
  16.                 else
  17.                         P1 = ~(0x80>>LEDIndex);       
  18.                 if(LEDIndex==7)
  19.                         LEDDirection = !LEDDirection;
  20.                 LEDIndex = (LEDIndex+1)%8;
  21.                 Delay1ms(100);
  22.         }
  23. }
复制代码

下载:
4e46dc67290d10bad76915cacf2700e4.rar (61.07 KB, 下载次数: 9)








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