【资源下载】下载地址如下:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
测温,温度可设定,继电器电路,数码管显示。此系统用于控温,当设定温度高于实际温度时,继电器吸合加热单元加热,当实际温度大于设定温度时,继电器释放。
#define uchar unsigned char #define uint unsigned int #define DATAPORT P0 sbit RED_ALARM=P1^0; sbit WRITE_ALARM=P1^1; sbit GREEN_ALARM=P1^2; //绿色指示灯 sbit BLUE_ALARM=P1^3; sbit P1_4=P1^4; //时钟调整 sbit P1_5=P1^5; //时钟加 sbit P1_6=P1^6; //时钟减 sbit DQ = P1^7; sbit L1=P2^3; sbit L2=P2^2; sbit L3=P2^1; sbit L4=P2^0; //定义ds18b20通信端口 sbit sda=P2^4; //IO口定义 sbit scl=P2^5; //LCD使能信号 sbit ad_busy=P3^2; //adc中断方式接口 sbit OUT=P3^7; sbit anjian=P2^6;// sbit RELAY=P2^7;// /******延时程序*******/ void delay2(unsigned int m) { unsigned int i,j; for(i=m;i>0;i--) for(j=60;j>0;j--); } uchar ad_data; //ad采样值存储 uchar seconde; //定义并初始化时钟变量 uchar minite; uchar hour; uchar mstcnt=0; uchar temp1,temp2,temp,xs; //温度显示变量 uchar t,set; uchar K; bit ON_OFF=0; bit outflag; bit write=0; void init_timer0(void); //定时器初始化 void keyscan(void ); //键盘扫描子程序 void set_adj(void); void inc_key(void); void dec_key(void); void delay_18B20(unsigned int i);// void Init_DS18B20(void) ; uchar ReadOneChar(void); void WriteOneChar(unsigned char dat); void ReadTemperature(void); void ad0809(void); void playalarm(void); void display(); void DelayMs(uint ms) { uchar t; while(ms--)for(t=0;t<8;t++); }