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

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

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

51單片機(jī)流水燈多種方法實(shí)現(xiàn)

[復(fù)制鏈接]
ID:524018 發(fā)表于 2019-4-28 22:27 | 顯示全部樓層 |閱讀模式


原代碼:


#include<reg52.h>
#include<intrins.h>//字符循環(huán)移動(dòng)函數(shù)庫(kù)
void delays()//延遲
{        
        int x,y;
           for(x=0;x<110;++x)        
        for(y=0;y<1000;++y);
}
         
void delayms(unsigned int xms)//x ms延遲
{
          unsigned int c,h;
          for(c = 0; c<xms; ++c)
        for(h = 0; h<110; ++h);
}


void main()
{        
        //從左到右,再?gòu)挠业阶蟮牧魉疅?/font>
        unsigned char j;
        unsigned char k;
        unsigned char temp;
        int i=0;
        P2 = 0xff;
        delays();
        temp=0x7f;


        for(k=0;k<7;k++)
        {        
                P2=temp;
                 delays();
                 temp=_cror_(temp,1);        //字符循環(huán)右移實(shí)現(xiàn)右移        
        }


        for(j=0;j<8;j++)
        {
                P2=temp;
                 delays();
                 temp=_crol_(temp,1);        //字符循環(huán)左移實(shí)現(xiàn)左移        
        }
        
        /*另外一種思路,用移位運(yùn)算符實(shí)現(xiàn)
        unsigned char a,i;
        a=0xfe;
        for(i=0;i<7;i++)
        {
                P2=a;
                delays();
                a=a<<1;//1移動(dòng),其他補(bǔ)零
                a=a|0x01;//左移一位后與0x01相或(只要滿足一個(gè)條件)        0000 0001
                // //或a=a|0x00;逐個(gè)點(diǎn)亮
        }
        a=0x7f;
        for(i=0;i<7;i++)
        {
                P2=a;
                delays();
                a=a>>1;//1移動(dòng),其他補(bǔ)零
                a=a|0x80;//右移一位后與0x80相或(只要滿足一個(gè)條件)        1000 0000
                // //或a=a|0x00;逐個(gè)點(diǎn)亮
        }*/


        /*用數(shù)組實(shí)現(xiàn)從兩側(cè)到中間,再?gòu)闹虚g到兩側(cè)流水燈
        int e;
        int i=0;
        unsigned char d[]={0x7e,0xbd,0xdb,0xe7};//定義亮燈熄燈數(shù)組


        for(e=0;e<3;e++)                         //兩側(cè)到中間
        {        
                P2=d[e];
                delays();
        }


        for(e=3;e>=0;e--)                         //中間到兩側(cè)
        {
                P2=d[e];
                delays();
        }*/
}

新手上路,請(qǐng)多指教,謝謝!





評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表