欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 基于51單片機(jī)的不同模式流水燈程序(3種方法) [打印本頁]

作者: linminjy    時(shí)間: 2021-11-10 15:29
標(biāo)題: 基于51單片機(jī)的不同模式流水燈程序(3種方法)
1.延時(shí)函數(shù):i==500
2.從一個(gè)LED變到另一個(gè)LED間要添加延時(shí)函數(shù)(間隔要適度),否則變化太快仿佛在抖動(dòng)。
3.key()函數(shù)中添加while(KEY==0);  檢測(cè)按鍵是否彈起,否則按鍵計(jì)數(shù)可能不對(duì)

仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #include<reg51.h>
  2. #define uchar unsigned char
  3. void delay()
  4. {
  5.         uchar a,b;
  6.         for(a=500;a;a--)
  7.         {
  8.         for(b=500;b;b--);
  9.         }
  10. }
  11. void main()
  12. {
  13.         unsigned char count=0;
  14.         unsigned char num=0;
  15.         while(1){
  16.                 while(((num%3)==0)&&(P2!=0xFE))
  17.                 {
  18.                         P0=~(0x01<<count);
  19.                         delay();
  20.                         count++;
  21.                         if(count>=8)
  22.                                 count=0;
  23.                 }
  24.                 while(((num%3)==1)&&(P2!=0xFE))
  25.                 {
  26.                         P0=~(0x80>>count);
  27.                         delay();
  28.                         count++;
  29.                         if(count>=8)
  30.                                 count=0;
  31.                 }
  32.                 while(((num%3)==2)&&(P2!=0xFE))
  33.                 {
  34.                         P0=~(0x01<<count);
  35.                         delay();
  36.                         count=count+2;
  37.                         if(count==8){
  38.                                 count=1;
  39.                         }
  40.                         if(count==9){
  41.                                 count=0;
  42.                         }
  43.                 }
  44.                 if(P2==0xFE){
  45.                         num=num+1;
  46.                 }
  47.                 while(P2==0xFE);
  48.         }
  49. }
復(fù)制代碼

所有資料51hei附件下載:
實(shí)驗(yàn)三.zip (61.61 KB, 下載次數(shù): 15)






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