蓝桥杯单片机开发板-DS18B20温度检测器的使用

本文主要介绍了如何使用蓝桥杯单片机开发板结合DS18B20传感器进行温度检测。通过解析`main.c`函数和`onewire.c`、`onewire.h`相关代码,详细阐述了单片机与DS18B20的连接及数据读取过程,为嵌入式硬件学习者提供了实战参考。
摘要由CSDN通过智能技术生成

main.c函数

#include "reg52.h"
#include "onewire.h"
 
unsigned char  duanma[10]={
   0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char  duanma_x[10]={
   0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
unsigned int   temp=0; 

void systeminitial();
void HC138(unsigned char channel);
void Delay_SMG(unsigned int t);
void DisplaySMG_Bit(unsigned char pos,unsigned char dat);
void DisplaySMG_temp();
void Delay(unsigned int t);
void Read_DS18B20_temp();

void main()
{
   
	systeminitial();
  while(1)
  {
   
		Read_DS18B20_temp();
		DisplaySMG_temp();
  }
}

void Delay(unsigned int t)
{
   
	 while(t--)
	 {
   
	 	 DisplaySMG_temp();
	 }
}

void DisplaySMG_temp()
{
   
		DisplaySMG_Bit(6,duanma[temp%10]);
		Delay_SMG(200);
		HC138(6);P0=0X00;HC138(0)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不知何时归家

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值