當前位置:編程學習大全網 - 網站源碼 - 誰能幫我翻譯下這個C語言源碼

誰能幫我翻譯下這個C語言源碼

應該是個流水燈左右閃移和程序

#include <REGX52.H>//頭文件包含

//毫秒延時子函數

void Delay1ms(unsigned int count)

{

unsigned int i,j;

for(i=0;i<count;i++)

for(j=0;j<120;j++);

}

//主函數入口

main()

{

unsigned char LEDIndex = 0;//定義變量

bit LEDDirection = 1;//定義位變量

while(1)//主死循環,讓單片機壹直工作

{

if(LEDDirection)//如果LEDDirection為真

P1 = ~(0x01<<LEDIndex);//LEDIndex的值左移1位後取反後給P1口輸出

else//如果LEDDirection為0

P1 = ~(0x80>>LEDIndex); //1000 0000右移LEDIndex位後取反後給P1口輸出

if(LEDIndex==7)//如果為LEDIndex=7則取反LEDDirection的值

LEDDirection = !LEDDirection;

LEDIndex = (LEDIndex+1)%8;//LEDIndex+1後除以8的余數再給LEDIndex

Delay1ms(100);//延時100毫秒

}

}

  • 上一篇:android studio 怎麽給apk簽名
  • 下一篇:比如加息了 跟黃金股有關系麽 關系大麽 比如恒邦股份
  • copyright 2024編程學習大全網