資源簡(jiǎn)介
基于何泰單片機(jī)開(kāi)發(fā)的智能加濕器C程序代碼 能完成 快速加濕、加濕、保濕三檔功率調(diào)節(jié)
代碼片段和文件信息
#include?
void?SEND?(void);
void?FIND?(void);
void?CCTL?(void);
void?COM??(void);
void?DELAY?(void);
void?SET?(void);
void?READ?(void);
#pragma?vector?SEND??@?0x08
typedef?unsigned?char?U8;?
int?U8T_data_H_tempU8T_data_L_tempU8RH_data_H_tempU8RH_data_L_tempU8checkdata_temp;
int?U8T_data_HU8T_data_LU8RH_data_HU8RH_data_LU8checkdata;
int?U8comdataU8FLAGU8temp;
const?unsigned?char?Tab1[10]={0x3F0x060x5B0x4F0x660x6D0x7D0x070x7F0x6F};
const?unsigned?char?Tab[4]={0x7f0xbf0xdf0xef};
unsigned?char?temp[4];
unsigned?char?temp_cnt;
unsigned?char?std_RH;
unsigned?char?scrFLG;
char?seter;
char?outer;
const?unsigned?char?Tab_RH[14]={4042434446485051525351504845};
void?Init_time();
?void?Init_time(void)??//定時(shí)器初始化函數(shù)
{
_emi=1;???//總中斷允許
????_eei=1;
_et0i=1;???//?定時(shí)器中斷允許
//_et1i=1;
_t0m0=0; //設(shè)為定時(shí)模式,內(nèi)部時(shí)鐘?8M
_t0m1=1;
// _tmr0h=0x00;
?//???_tmr0l=0x00;
????_tmr0h=0xfb;
????_tmr0l=0xff;
????_t0psc0?=?1;
_t0psc1?=?1;
_t0psc2?=?1;//4分頻
_t0on=1;
//_t1on=1 ;//啟動(dòng)定時(shí)器
}
main??()
{?
????_pac=0;//I/O輸出
????_pdc=0;//I/O輸出
_delay(50000);
???while(1)
{??????Init_time();
???????if(scrFLG==1)
?????{??
??????READ?();
??????FIND?();
??CCTL();
?????}
?????if(_pa5==1)?????SET();
?????
}
}
??
???void?FIND?()
{??
?int?i?;
?i=U8T_data_H-15;
?std_RH=Tab_RH[i];
}?
???void?CCTL()
?{?
??int?i;
??
??if?(std_RH>U8RH_data_H)
??{
????i=std_RH-U8RH_data_H;
????i=i/8;
????outer=i+seter;
????if?(_pa4==0)?_pc2=1;
????else?if(_pa4==1)
?????{
????? if?(outer==0)??_pc2=1;
????????else?if(outer==1)??_pc3=1;
??????????else??????????_pc4=1;
?????}
???}
??
?
??else?return;?
??
??
?}?
???
?//中斷設(shè)置程序??
???void?SEND?()
{
???????_tmr1h=0xfb;
???????_tmr1l=0xff;
???????if?(scrFLG==1)
??????{
_pb=Tab1[temp[temp_cnt]];
_pa=Tab[temp_cnt];
temp_cnt=temp_cnt+1;
評(píng)論
共有 條評(píng)論