实现效果如图:
main.c
#include<string.h>
#include"typedef.h"
#include"lcd1602.h"
#include"ds18b20.h"
uchar str1[]={
"Test by Ds18b20."};
uchar str2[11]={
"Temp: "};
void main()
{
uchar i;
lcd1602_init();
while(1)
{
DS18B20_Read_Temperature();
Temperature_Convert();
lcd1602_write_cmd(0x80);
for(i=0;i<strlen(str1);i++)
{
lcd1602_write_dat(str1[i]);
}
lcd1602_write_cmd(0xC0);
for(i=0;i<11;i++)
{
lcd1602_write_dat(str2[i]);
}
}
}
lcd1602.c
#include<reg52.h>
#include"delay.h"
#include"typedef.h"
#include"lcd1602.h"
sbit RS=P2^6;
sbit RW=P2^5;
sbit EN=P2^7;
sbit P07=P0^7;
bit lcd1602_read_status()
{
uchar temp;
RW=1;delay(2);
RS=0;delay(2);
EN=1;delay(2);
temp=P0;delay(2