本帖最后由 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
|