#include < reg51.h > #include < intrins.h > #define uchar unsigned char #define uint unsigned int sbit DQ = P2^7 ; //定义 DS18B20 端口 DQ void reset(); //DS18B20 复位函数 void write_byte(uchar val); //DS18B20 写命令函数 uchar read_byte(void); //DS18B20 读 1 字节函数 void read_temp(); //温度读取函数 void work_temp(); //温度数据处理函数 sbit BEEP=P2^5 ; //蜂鸣器驱动线 bit presence ; sbit LCD_RS = P3^5 ; sbit LCD_RW = P3^6 ; sbit LCD_EN = P3^7 ; uchar code cdis1[ ] = {" SETTEMP: 50.C "} ; uchar code cdis2[ ] = {" TESTTEMP: . C "} ; uchar code cdis3[ ] = {" DS18B20 ERR0R "} ; uchar code cdis4[ ] = {" PLEASE CHECK "} ; unsigned char data temp_data[2] = {0x00,0x00} ; unsigned char data display[5] = {0x00,0x00,0x00,0x00,0x00} ; unsigned char code ditab[16] = {0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x05,0x06,0x06,0x07,0x08,0x08,0x09,0x09} ; void beep() ; unsigned char code mytab[8] = {0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00} ; #define delayNOP() ; {_nop_() ;_nop_() ;_nop_() ;_nop_() ;} ; /*******************************************************************/ void delay1(int ms) { unsigned char y ; while(ms--) { for(y = 0 ; y<250 ; y++) { _nop_() ; _nop_() ; _nop_() ; _nop_() ; } } } /******************************************************************/ /*检查LCD 忙状态 */ /*lcd_busy 为1 时,忙,等待。lcd-busy 为0 时,闲,可写指令与数据。 */ /******************************************************************/ bit lcd_busy() { bit result ; LCD_RS = 0 ; LCD_RW = 1 ; LCD_EN = 1 ; delayNOP() ; result = (bit)(P1&0x80) ; LCD_EN = 0 ; return(result) ; } /*写指令数据到 LCD */ /*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */ /*******************************************************************/ void lcd_wcmd(uchar cmd) { while(lcd_busy()) ; LCD_RS = 0 ; LCD_RW = ...