找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3167|回復: 2
打印 上一主題 下一主題
收起左側

單片機溫度檢測proteus仿真+代碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:479248 發(fā)表于 2019-2-27 18:03 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
部分源碼:
#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)          //延時函數(shù)
{   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)   //寫一個字節(jié)函數(shù)
{
    uchar i;
    for(i=0;i<8;i++)
    {
       DQ=0;   DQ=dat&0x01;
       delay(4);
       DQ=1;   dat=dat>>1;
    }
}
uchar read_byte( )    //讀一個字節(jié)函數(shù)
{
    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( )    //讀取溫度函數(shù)
{
    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, 下載次數(shù): 67)

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

單片機溫度檢測.rar

53.13 KB, 下載次數(shù): 49, 下載積分: 黑幣 -5

Proteus仿真及代碼

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:731180 發(fā)表于 2020-4-17 10:50 | 只看該作者
可以聯(lián)系一下嗎  想學習一下源碼
回復

使用道具 舉報

板凳
ID:737692 發(fā)表于 2020-4-26 15:29 | 只看該作者
這是檢測溫度并報警嗎
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表