ds18b20c语言keil,DS18B20温度检测调节程序(C代码)

  • Post author:
  • Post category:其他


#include”reg52.h”

#include”intrins.h”

#include”absacc.h”

#define uint unsigned int

#define uchar unsigned char

uchar code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //共阳管0~9

uchar code tab_motor_1[]={0x03,0x06,0x0c,0x09}; //电机正转 向上

uchar code tab_motor_2[]={0x09,0x0c,0x06,0x03}; //电机反转 向下本文引用地址:http://www.eepw.com.cn/article/201611/315460.htm

sbit ds18b20_in=P2^4; //温度传感器数据线位定义

sbit dht11=P2^2; //温湿度传感器 数据线位定义

sbit SPEAKER=P2^3; //报警器

//sbit FAN=P2^5; //电风扇

sbit HEATERS=P3^1;

sbit FAN=P3^0;

//******************全局变量定义**********************************

uchar tempL=0,tempH=0; //ds18b20读取值

uchar Set_Temp_H=30,Set_Temp_L=24;//温度边界值设定值

uchar Set_Humi_H,Set_Humi_L;

uchar Set_Illu_H,Set_Illu_L;

uchar flag_judge_temp,flag_judge_humi,flag_judge_illu; //标志位定义

float temperature,illumination,humidity; //温度值、光照值、湿度值?

//**********************延时子程序************************

void delay(uint time)

{

uint n=0;

while(n {n++;}

return;

}

void delay1()

{

int k;

for(k=0;k<600;k++);

}

voi