找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2520|回复: 18
收起左侧

求大佬看看温度报警器出现的这个问题can't open file 'DS18B20.h'该怎么解决啊

  [复制链接]
ID:856835 发表于 2020-12-13 15:25 | 显示全部楼层 |阅读模式
本帖最后由 15836216717 于 2020-12-13 15:27 编辑

#include <AT89X52.h>
#include "DS18B20.h"   
#define uint unsigned int
#define uchar unsigned char   //???
#define SET  P3_1    //?????
#define DEC  P3_2    //?????
#define ADD  P3_3    //?????
#define BEEP P3_7    //?????
bit shanshuo_st;    //??????
bit beep_st;     //???????
sbit DIAN = P2^7;        //???
uchar x=0;      //???
signed char m;     //???????
uchar n;      //???????
uchar set_st=0;     //????
signed char shangxian=38;  //??????,????38
signed char xiaxian=5;   //??????,????38
uchar code  LEDData[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff};
/*****?????*****/
void Delay(uint num)
{
while( --num );
}
/*****??????0*****/
void InitTimer(void)
{
  TMOD=0x1;
  TH0=0x3c;
  TL0=0xb0;     //50ms(??12M)
}
/*****???0??????*****/
void timer0(void) interrupt 1
{
TH0=0x3c;
TL0=0xb0;
x++;
}
/*****????0????*****/
void int0(void) interrupt 0
{

EX0=0;      //?????0
if(DEC==0&&set_st==1)
{
  shangxian--;
  if(shangxian<xiaxian)shangxian=xiaxian;
}
else if(DEC==0&&set_st==2)
{
  xiaxian--;
  if(xiaxian<0)xiaxian=0;
}
}
/*****????1????*****/
void int1(void) interrupt 2
{
EX1=0;      //?????1
if(ADD==0&&set_st==1)
{
  shangxian++;
  if(shangxian>99)shangxian=99;
}
else if(ADD==0&&set_st==2)
{
  xiaxian++;
  if(xiaxian>shangxian)xiaxian=shangxian;
}  
}
/*****????*****/
void check_wendu(void)
{
uint a,b,c;
c=ReadTemperature()-5;  //????????DS18B20?????
a=c/100;     //????????
b=c/10-a*10;    //????????
m=c/10;      //???????
n=c-a*100-b*10;    //???????
if(m<0){m=0;n=0;}   //????????
if(m>99){m=99;n=9;}   //????????   
}
/*****???????????*****/
Disp_init()   
{
P2 = 0xbf;      //??-
P1 = 0xf7;
Delay(200);
P1 = 0xfb;
Delay(200);   
P1 = 0xfd;
Delay(200);
P1 = 0xfe;
Delay(200);
P1 = 0xff;         //????
}
/*****???????*****/
Disp_Temperature()     //????
{
P2 =0xc6;      //??C
P1 = 0xf7;
Delay(300);
P2 =LEDData[n];    //????
P1 = 0xfb;
Delay(300);
P2 =LEDData[m%10];    //????
DIAN = 0;         //?????
P1 = 0xfd;
Delay(300);
P2 =LEDData[m/10];    //????
P1 = 0xfe;
Delay(300);
P1 = 0xff;         //????
}
/*****?????????*****/
Disp_alarm(uchar baojing)
{
P2 =0xc6;      //??C
P1 = 0xf7;
Delay(200);
P2 =LEDData[baojing%10]; //????
P1 = 0xfb;
Delay(200);
P2 =LEDData[baojing/10]; //????
P1 = 0xfd;
Delay(200);
if(set_st==1)P2 =0x89;
else if(set_st==2)P2 =0xc7; //??H???L??
P1 = 0xfe;
Delay(200);
P1 = 0xff;         //????
}
/*****?????*****/
void Alarm()
{
if(x>=10){beep_st=~beep_st;x=0;}
if((m>=shangxian&&beep_st==1)||(m<xiaxian&&beep_st==1))BEEP=0;
else BEEP=1;
}
/*****???*****/
void main(void)
{
    uint z;
InitTimer();    //??????
EA=1;      //??????
TR0=1;
ET0=1;      //?????0
IT0=1;        
IT1=1;
check_wendu();
check_wendu();
for(z=0;z<300;z++)
{
  Disp_init();        
  }
}


还有以下问题
1.c(2): warning C318: can't open file 'DS18B20.h'
1.c(73): warning C206: 'ReadTemperature': missing function-prototype
1.c(94): warning C290: missing return value
1.c(112): warning C290: missing return value
1.c(130): warning C290: missing return value


回复

使用道具 举报

ID:275826 发表于 2020-12-13 17:55 | 显示全部楼层
缺少 DS18B20.h 头文件
回复

使用道具 举报

ID:452950 发表于 2020-12-13 18:34 | 显示全部楼层
代码不全是这样的,你只有主程序,没有温度传感器的头文件
回复

使用道具 举报

ID:859624 发表于 2020-12-13 19:30 | 显示全部楼层
没有DS18B20的头文件
回复

使用道具 举报

ID:860332 发表于 2020-12-15 10:12 | 显示全部楼层
光写了DS18B20头文件,却没有添加DS18B20的文件
回复

使用道具 举报

ID:382454 发表于 2020-12-15 10:32 | 显示全部楼层
头文件没有放到相应的目录。
回复

使用道具 举报

ID:844772 发表于 2020-12-15 10:44 | 显示全部楼层
都是简单问题啊:1.#include <AT89X52.h> #include "DS18B20.h"   ,是不是双引号打错了?2。是错误一导致的;3.这三个错都是声明函数前没加void,或者随便return  个值也行。
回复

使用道具 举报

ID:318489 发表于 2020-12-15 10:46 | 显示全部楼层
没18b20的头文件
回复

使用道具 举报

ID:429356 发表于 2020-12-15 17:29 | 显示全部楼层
你这是拿了别人的程序吧,而且还没拿完。DS18B20.h那边还有定义呢
回复

使用道具 举报

ID:854384 发表于 2020-12-18 19:43 | 显示全部楼层
DS18B20.h是一个头文件,主函数里面会用到其中函数,说以会报错
回复

使用道具 举报

ID:1053256 发表于 2023-1-15 15:32 | 显示全部楼层
glinfei 发表于 2020-12-15 10:44
都是简单问题啊:1.#include  #include "DS18B20.h"   ,是不是双引号打错了?2。是错误一导致的;3. ...

对,自己写的必须用””
回复

使用道具 举报

ID:944207 发表于 2023-1-15 23:08 | 显示全部楼层
DS18B20是单独定义了一个.h文件,这个函数里面又声明调用了DS18B20.h这个函数文件,应该是你的这个DS18
回复

使用道具 举报

ID:944207 发表于 2023-1-15 23:13 | 显示全部楼层
原文件应该是对DS18B20进行了单独的初始化,是一个.h文件,你给出的这个代码中开头对其进行了声明以及调用,但是软件没有在工程文件夹中找到这个DS18B20.h这个文件,就会出现这样的报错了,再找一下这个代码的出处,把代码下载完全就好了,下面的warning是因为没有调用DS18B20.h里面的函数,所以DS18B20没有初始化,不能正常工作,也就没有return
回复

使用道具 举报

ID:420836 发表于 2023-1-15 23:51 | 显示全部楼层
该错误是由于编译器无法找到包含的头文件引起的。
回复

使用道具 举报

ID:1034262 发表于 2023-1-16 13:01 | 显示全部楼层
无法打开你指定的头文件,检查文件路径,或者是否有这个头文件。
回复

使用道具 举报

ID:748788 发表于 2023-1-16 13:20 | 显示全部楼层
先注掉这一行试试——#include "DS18B20.h" 。
回复

使用道具 举报

ID:1074004 发表于 2023-4-28 15:52 | 显示全部楼层
没有返回变量
回复

使用道具 举报

ID:1050969 发表于 2023-4-28 23:16 | 显示全部楼层
1、检查是否有“DS18B20.H"这个文件。
2.检查kell软件中是否把”ds18b20.h"这个文件所在路径添加到工程中。
回复

使用道具 举报

ID:1034262 发表于 2023-4-29 15:15 | 显示全部楼层
缺少 "DS18B20.h" 文件,或文件路径不对。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表