標(biāo)題: Protues仿真實(shí)例(8051)-流水燈演示 [打印本頁(yè)]

作者: 1613130717    時(shí)間: 2017-12-23 21:17
標(biāo)題: Protues仿真實(shí)例(8051)-流水燈演示
Protues仿真實(shí)例(8051)-流水燈演示

單片機(jī)源程序如下:
  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. }
復(fù)制代碼

所有資料51hei提供下載:
Protues仿真實(shí)例(8051)-流水燈演示.zip (67.92 KB, 下載次數(shù): 7)







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1