欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: DS18B20溫度傳感器溫度報(bào)警,并將溫度上傳到上位機(jī),仿真和程序 [打印本頁(yè)]

作者: 1805220100    時(shí)間: 2020-12-5 11:52
標(biāo)題: DS18B20溫度傳感器溫度報(bào)警,并將溫度上傳到上位機(jī),仿真和程序
/****
* 【外部晶振】: 11.0592mhz       
* 【主控芯片】: STC89C52
* 【編譯環(huán)境】: Keil μVisio4
* 【程序功能】:                                                                                            
* 【使用說(shuō)明】: 實(shí)時(shí)采集當(dāng)前環(huán)境溫度值,并顯示于數(shù)碼管上。
                  同時(shí),當(dāng)溫度高于某一值時(shí)(此處設(shè)為40攝氏度)低于5也會(huì)響,蜂鳴器便會(huì)發(fā)出報(bào)警。
                  而當(dāng)?shù)陀谠撝禃r(shí),蜂鳴器自動(dòng)停止報(bào)警。以及上傳溫度到pc
               
**********************************************************************************/

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit DS=P2^2;           //define interface
uint temp;             // variable of temperature
uchar flag1;            // sign of the result positive or negative
sbit dula=P2^6;
sbit wela=P2^7;
sbit beep=P2^3;
uint num;
uchar A1,A2,A2t,A3;
void uart();//函數(shù)聲明

unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
                        0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char code table1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,
                        0x87,0xff,0xef};



//串口初始化
void uart()
{
        EA=1;//開(kāi)總中斷
        ES=1;//串口中斷允許位,ES=1允許串口中斷 ES=0禁止串口中斷,IE中斷允許寄存器
        SM0=0;SM1=1;//串口工作方式1,8位uart波特率可變
        REN=1;//串口允許接收
        TR1=1;//啟動(dòng)定時(shí)器1
        TMOD |= 0X20;//定時(shí)器1工作模式2,8位自動(dòng)重裝
        TH1=0XFD;
        TL1=0XFD;//設(shè)置波特率9600
}

void delay(uint count)      //delay
{
  uint i;
  while(count)
  {
    i=200;
    while(i>0)
    i--;
    count--;
  }
}
void mx()
{
        TI=1;
        SBUF=0x00;;//送sbuf
        while(!TI);
        TI=0;       
        delay(10);
}
void dsreset(void)       //send reset and initialization command
{
  uint i;
  DS=0;
  i=103;
  while(i>0)i--;
  DS=1;
  i=4;
  while(i>0)i--;
}
............完整代碼在文件中

屏幕截圖(95).png (150.42 KB, 下載次數(shù): 57)

屏幕截圖(95).png

DS18B20--溫度報(bào)警器,串口通信.rar

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






歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1