單片機(jī)制作媚眼激活儀的c代碼
void chushi(void) //進(jìn)主MAIN函數(shù)體時(shí)直接初始化
{
TMOD=0x01; //定時(shí)器定時(shí)模式
TH0=0x3c;
TL0=0xb0;
ET0=1;
EA=1;
TR0=1;
xuanled=1;
guanled=1;
rfled=1;
}
void chushi1(void) //對(duì)大循環(huán)的初始化
{
time=30; //開(kāi)機(jī)時(shí)時(shí)間初值為30分鐘
guanout=0; //光譜輸出為低電平
rfout=0; //RF發(fā)熱頭輸驅(qū)動(dòng)為低電平
xuanout=0; //旋磁輸出低電平
guannum=0; //待機(jī)時(shí),光譜為0狀態(tài)
xuanled=1;
guanled=1;
rfled=1;
duan=tab[10]; //開(kāi)段顯示,顯示中間筆段
gewela=0;
shiwela=0;
delay(2);
gewela=1;
shiwela=1;
}
void key(void) //按鍵檢測(cè)模塊
{
uchar a,num1;
keyio=0xff;
if(keyio!=0xff)
{
fmqout=0;
if(onandoff!=0)
{
for(a=100;a>0;a--)
display(time);
}
else
{ for(a=20;a>0;a--)
{
duan=tab[10]; //開(kāi)段顯示,顯示中間筆段
gewela=0;
shiwela=0;
delay(2);
gewela=1;
shiwela=1;
}
}
if(keyio!=0xff)
{
num1=keyio;
switch(num1)
{
case 0xfe: onandoff=~onandoff; //開(kāi)關(guān)機(jī)
break;
case 0xfd: b=0;
if((onandoff!=0)(time!=99)) //時(shí)間加
time++;
break;
case 0xfb: b=0;
if((onandoff!=0)(time!=0)) //時(shí)間減
time--;
break;
case 0xf7: if(onandoff!=0)
{
xuanout=~xuanout; //旋磁轉(zhuǎn)動(dòng)變量變化
if(xuanout!=0)
xuanled=0;
else xuanled=1;
}
break;
case 0xef: if(onandoff!=0) //光譜輸出變量變化
{
guannum++;
if(guannum==4)
guannum=0;
if(guannum!=0)
guanled=0;
else guanled=1;
if(guannum==1)
guanout=1;
else if(guannum==2)
guantime1=guantime2=15;
else if(guannum==3)
guantime1=guantime2=8;
else guanout=0;
}
break;
case 0xdf: if(onandoff!=0) //RF發(fā)熱變量變化
{
rfout=~rfout;
if(rfout!=0)
rfled=0;
else rfled=1;
}
break;
default:break;
}
}
}
}
void display(uchar min)//數(shù)碼管顯示模塊
{
uchar ge,shi;
shi=min/10;
ge=min%10;
duan=tab[shi];
shiwela=0;
delay(5);
shiwela=1;
duan=tab[ge];
xsdbit=xsd;
gewela=0;
delay(5);
gewela=1;
}
評(píng)論