欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
51單片機(jī)流水燈+花樣燈程序
[打印本頁(yè)]
作者:
思念、苦無(wú)藥
時(shí)間:
2018-6-21 17:15
標(biāo)題:
51單片機(jī)流水燈+花樣燈程序
#include <REGX51.H> //頭文件,定義單片機(jī)型號(hào)
#define uchar unsigned char //偽指令用uchar代替unsigned char
#define uint unsigned int //偽指令用uint代替unsigned int
uchar code a[6]={0xfa,0xf5,0xeb,0xd7,0xaf,0x5f}; //定義編譯數(shù)組
uchar code b[6]={0x5f,0xaf,0xd7,0xeb,0xf5,0xfa}; //定義編譯數(shù)組
void delay(uint x) //延時(shí)函數(shù)
{
uint y;
for(;x>0;x--)
for(y=100;y>0;y--);
}
void main(void) //函數(shù)的開(kāi)始,(void)表示有返回值
{
uint i;
uchar temp;
while(1) //while循環(huán)(1)循環(huán)條件
{
temp=0xfe;
for(i=0;i<8;i++)
{
P0=temp;
delay(300);
temp=(temp<<=1)|0x01; //temp值左移1位,從而實(shí)現(xiàn)流水燈效果,0x01表示在最右面補(bǔ)1
}
temp=0x7f;
for(i=0;i<8;i++)
{
P0=temp;
delay(300);
temp=(temp>>=1)|0x80; //temp值右移1位,從而實(shí)現(xiàn)流水燈效果,0x80表示在最左面補(bǔ)1
}
for(i=0;i<6;i++)
{
P0=a[i]; //遍歷數(shù)組a,將數(shù)組a中的每個(gè)元素賦給P0
delay(400);
}
for(i=0;i<6;i++)
{
P0=b[i]; //遍歷數(shù)組b,將數(shù)組b中的每個(gè)元素賦給P0
delay(400);
}
}
}
作者:
jiamingyang
時(shí)間:
2018-6-21 18:47
很簡(jiǎn)單,寫(xiě)的太復(fù)雜了
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1