找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2103|回復: 0
收起左側(cè)

Protues仿真實例(8051)-流水燈演示

[復制鏈接]
ID:265818 發(fā)表于 2017-12-23 21:17 | 顯示全部樓層 |閱讀模式
Protues仿真實例(8051)-流水燈演示
QQ截圖20171223211700.png
單片機源程序如下:
  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. }
復制代碼

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


回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表