找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2796|回复: 2
打印 上一主题 下一主题
收起左侧

单片机温度检测proteus仿真+代码

[复制链接]
跳转到指定楼层
楼主
部分源码:
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit shi=P2^0;   
sbit ge=P2^1;
sbit DQ=P2^2;
sbit C=P2^3;   
sbit D=P2^4;
uint temp;
void delay(uint t)          //延时函数
{   while(t--);   }
void init_ds18b20( )     //DS18B20初始化
{
    uchar n;
    DQ=1;   delay(8);
    DQ=0;   delay(80);  
    DQ=1;   delay(14);   
    n=DQ;   delay(20);       
}
void write_byte(uchar dat)   //写一个字节函数
{
    uchar i;
    for(i=0;i<8;i++)
    {
       DQ=0;   DQ=dat&0x01;
       delay(4);
       DQ=1;   dat=dat>>1;
    }
}
uchar read_byte( )    //读一个字节函数
{
    uchar i,value;
    for(i=0;i<8;i++)
    {
       DQ=0;   value>>=1;
       DQ=1;   if(DQ)   value|=0x80;   delay(4);
    }
        return value;
}
uchar readtemperature( )    //读取温度函数
{
    uchar a,b;
        uint t=0;
        init_ds18b20();   write_byte(0xcc);   write_byte(0x44);
        init_ds18b20();   write_byte(0xcc);   write_byte(0xbe);
        a=read_byte();    b=read_byte();
        t=b;    t<<=8;    t=t|a;    t=t*0.0625+0.5;
        return t;
}

778[T2`W(}4XL`Y$UB03BMB.png (36.46 KB, 下载次数: 60)

778[T2`W(}4XL`Y$UB03BMB.png

单片机温度检测.rar

53.13 KB, 下载次数: 49, 下载积分: 黑币 -5

Proteus仿真及代码

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:731180 发表于 2020-4-17 10:50 | 只看该作者
可以联系一下吗  想学习一下源码
回复

使用道具 举报

板凳
ID:737692 发表于 2020-4-26 15:29 | 只看该作者
这是检测温度并报警吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表