標(biāo)題: 單片機(jī)雙led燈移動(dòng)程序 [打印本頁(yè)]

作者: liuda    時(shí)間: 2015-1-22 02:06
標(biāo)題: 單片機(jī)雙led燈移動(dòng)程序
//2led   move to   left &right#include<reg52.h>
void delay(unsigned int x);
void main()
{ int i;

        while(1)
        {
        P0=0x03;
        delay(30000)        ;
                for (i=0;i<6;i++)
                {
                P0<<=1;//沒有移動(dòng)的現(xiàn)象,我懷疑是沒有延時(shí)的原因,閃爍的太快了,以至于把眼睛騙了
                delay(30000)        ;
                }         
          if(P0==0XC0)
          {
                 for (i=0;i<6;i++)
                {
                P0>>=1;
                delay(30000)        ;
                }
          }
        }
}
void delay(unsigned int x)
{
while(--x);
}







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