#include
# define DATA P0//1602???????????
//ROM????????????
# define READ_ROM 0 x33//?? ROM
# define SKIP_ROM 0 XCC//?????? ROM
# define MATCH_ROM 0 x55//??????? ROM
# define SEARCH_ROM 0 xf0//?????? ROM
# define ALARM_SEARCH 0 xec//? 澯??????
//? 洢????????????????
# define ANEW_MOVE 0 xb8//??????? Mu??? E ^ 2??????
# define READ_POWER 0 xb4//?????
# define TEMP_SWITCH 0 x44//?????? As a
# define READ_MEMORY 0 xbe//????? 洢??
# define COPY_MEMORY 0 x48//??????????? 洢??
# define WRITE_MEMORY 0 x4e//д??????? 洢??
//?????? 洢??
Typedef struct tagTempData
{
Unsigned char btThird;//?? Lambda??????
Unsigned char btSecond;//? Lambda??????
Unsigned char btFirst;//?? Lambda??????
Unsigned char btDecimal;//С???????? Lambda??????
Unsigned char btNegative;//????????
} TEMPDATA;
TEMPDATA m_TempData;
//???????????
Sbit DQ=P1 ^ 6;//????????
Sbit RS=P2 ^ 0;
Sbit RW=P2 ^ 1;
Sbit E=P2 ^ 2;
Sbit K1=P2 ^ 5;
Sbit K2=P2 ^ 6;
Sbit K3=P2 ^ 7;
Sbit LED1=P3 ^ 2;
Sbit LED2=P3 ^ 3;
Sbit LED3=P3 ^ 4;
Sbit LED4=P3 ^ 5;
Sbit LED5=P3 ^ 6;
Sbit LED6=P3 ^ 7;
Sbit relay1 P1=^ 0;
Sbit relay2 P1=^ 1;
The static unsigned char ti=0;
Unsigned char BJ1=0, BJ2=0, BJ3=0, war1=30, war2=32, state=0;
//DS18B20??? Seem? And????????? GetROMSequence ()???????? P1??????? (?????? 8?? )
//const unsigned char code ROMData1 [8]={x4a x28 0, 0 XFF, 0, 0 x7c, 0 x63, 0 x14, 0 x02, 0 x8c};//U1
Const unsigned char code ROMData1 [8]={xc5 x28 0, 0 x33, 0, 0 xb8, 0 x00 to 0 x00 to 0 x00 to 0 xd7};//U1
Const unsigned char code ROMData2 [8]={xc5 x28 0, 0 x30, 0, 0 xb8, 0 x00 to 0 x00 to 0 x00 to 0 x8e};//U2
Const unsigned char code ROMData3 [8]={xc5 x28 0, 0 x31, 0, 0 xb8, 0 x00 to 0 x00 to 0 x00 to 0 xb9};//U3
//? ж???????
Void Busy ()
{
DATA=https://bbs.csdn.net/topics/0xff;
RS=0;
RW=1;
While (DATA & amp; 0 x80)
{
E=0;
E=1;
}
E=0;
}
//д????????
Void WriteCommand (unsigned char btCommand)
{
Busy ();
RS=0;
RW=0;
E=1;
DATA=https://bbs.csdn.net/topics/btCommand;
E=0;
}
//д???????????
Void WriteData (unsigned char btData)
{
Busy ();
RS=1;
RW=0;
E=1;
DATA=https://bbs.csdn.net/topics/btData;
E=0;
}
//???????????
Void the Clear ()
{
WriteCommand (1);
}
//???????
Void Init ()
{
WriteCommand (0 x0c);//??????? And?????????
WriteCommand (0 x06);//???????????????????????????
WriteCommand (0 x38);//????????????? : 8 lambda 2?? 5 x7??????
}
//????????????????
Void DisplayOne (bit bRow, unsigned char btColumn, unsigned char btData, bit bIsNumber)
{
If (bRow) WriteCommand (0 xc0 + btColumn);
The else WriteCommand (0 x80 + btColumn);
If (bIsNumber) WriteData (btData + 0 x30);
The else WriteData (btData);
}
//??????????????????
Void DisplayString (bit bRow, unsigned char btColumn, unsigned char * pData)
{
While (* pData!='\ 0')
{
If (bRow) WriteCommand (0 xc0 + btColumn);//???????? 1??
The else WriteCommand (0 x80 + btColumn);//???????? 0??
* (pData++ WriteData ());//????????????????
BtColumn++;//???????????
}
}
//??? 16 us???????
Void Delay16us ()
{
Unsigned char a;
For (a=0; A. & lt; 4. +);
}
//??? 60 us???????
Void Delay60us ()
{
Unsigned char a;
For (a=0; A. & lt; 18; +);
}
//??? 480 us???????
Void Delay480us ()
{
Unsigned char a;
For (a=0; A. & lt; 158; +);
}
//??? 240 us???????
Void Delay240us ()
{
Unsigned char a;
For (a=0; A. & lt; 78; +);
}
//??? 500 ms???????
Void Delay500ms ()
{
Unsigned char a, b, c;
For (a=0; A. & lt; 250; +)
For (b=0; B & lt; 3; B++)
For (c=0; C & lt; 220; C + +);
}
//о????????
Void Initialization ()
{
While (1)
{
DQ=0;
Delay480us ();//??? 480 us
Delay240us ();
DQ=1;
Delay60us ();//??? 60 us
if(! DQ)//??? Ds18b20????????
{
DQ=1;
Delay480us ();//??? 480 us
break;
}
}
}
//д???????? (????? Lambda??? д)
Void WriteByte (unsigned char btData)
{
unsigned char i; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull