標(biāo)題: 單片機(jī)左右來(lái)回的流水燈實(shí)現(xiàn) [打印本頁(yè)]

作者: 15738536901    時(shí)間: 2018-12-24 18:58
標(biāo)題: 單片機(jī)左右來(lái)回的流水燈實(shí)現(xiàn)
希望對(duì)大家有所幫助

單片機(jī)源程序如下:
  1. #include <reg52.h>
  2. #include <intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int

  5. void DelayMS(uint x)
  6. {
  7.         uchar t;
  8.         while(x--)
  9.         {
  10.                  for(t=120;t>0;t--);
  11.         }
  12. }

  13. void main()
  14. {
  15.         uchar i;
  16.         P2=0x01;
  17.         while(1)
  18.         {
  19.                  for(i=7;i>0;i--)
  20.                 {
  21.                         P2=_crol_(P2,1);
  22.                         DelayMS(150);
  23.                 }
  24.                 for(i=7;i>0;i--)
  25.                 {
  26.                          P2=_cror_(P2,2);
  27.                         DelayMS(150);
  28.                 }
  29.         }
  30. }
復(fù)制代碼

所有資料51hei提供下載:
6 定時(shí)器計(jì)數(shù)器.zip (147.61 KB, 下載次數(shù): 10)








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