用ds18b20测试温度并且显示在LCD1602上

本文介绍如何使用DS18B20传感器进行温度测量,并将结果显示在LCD1602显示屏上,详细阐述了在单片机环境下实现这一功能的过程。
摘要由CSDN通过智能技术生成

主函数文件:

#include <reg52.h>
#include <intrins.h>
#include <stdio.h>
#include "./delay/delay.h"

sbit ds = P1^0;
bit ack = 0;

sbit RS = P2^4;
sbit RW = P2^5;
sbit E  = P2^6;

#define LCDPORT P0
#define LCD_WRITE_DATA 1
#define LCD_WRITE_COM  0

void lcd1602_write(unsigned char byte,unsigned char flag)
{
	  if(flag)
		{
			  RS = 1;
		}
		else
		{
			  RS = 0; 
		}
		RW = 0; 
		E = 1; 
		LCDPORT = byte;
		delay_us(5);
		E = 0; 
}

void lcd1602_dis_str(unsigned char x, unsigned char y, unsigned char *str)
{
	  if((x > 15) || (y > 1))
		{
			  return ;
		}
		if(0 == y)
		{
			  lcd1602_write(0x80 + x,LCD_WRITE_COM);
		}
		else
		{
			  lcd1602_write(0x80 + 0x40 + x,LCD_WRITE_COM);
		}
		while(*str != '\0')
		{
			  lcd1602_write(*str,LCD_WRITE_DATA);
			  str++;
		}
}

void lcd_init()
{
	  delay_ms(15);
	  lcd1602_write(
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值