日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > DS18B20+PIC測溫用1602顯示溫度C程序

          DS18B20+PIC測溫用1602顯示溫度C程序

          作者: 時間:2016-11-30 來源:網(wǎng)絡 收藏
          //熟悉使用單片機運用DS18B20溫度傳感器測試溫度,并用1602顯示屏顯示溫度

          //1、第一行顯示:Temperature
          //2、第二行顯示:實測溫度值
          //**************************************************

          本文引用地址:http://yuyingmama.com.cn/article/201611/323921.htm

          //**************************************************
          //硬件設置:
          //1、SW2,SW4開關全部斷開
          //2、插上DS18B20溫度傳感器
          //**************************************************

          //**************************************************
          //*****************定義頭文件**********************
          //**************************************************
          #include
          #include "delay.h"

          //**************************************************
          //******************定義配置位*********************
          //**************************************************
          __CONFIG(0x3545);
          //FLASH代碼不保護,RB6和RB7為調(diào)試模式,F(xiàn)LASH不寫保護,數(shù)據(jù)代碼不保護
          //RB3為數(shù)字IO口,低電壓復位使能,上電延時開,看門狗開,4M晶體XT振蕩器

          //**************************************************
          //******************定義常量***********************
          //**************************************************
          #define uchar unsigned char
          #define uint unsigned int

          //**************************************************
          //***************定義DS18B20引腳*******************
          //**************************************************
          #define DQ RE0
          #define DQ_IO TRISE0

          //**************************************************
          //******************定義LCD引腳*********************
          //**************************************************
          #define RS RA1
          #define RW RA2
          #define E RA3

          //**************************************************
          //******************定義變量***********************
          //**************************************************
          uchar lowtemp,hightemp; //低8位溫度變量,高8位溫度變量
          uchar zhengshu,xiaoshu; //溫度整數(shù)變量,溫度小數(shù)變量
          uint temperature; //轉(zhuǎn)換后的溫度值BCD碼形式
          uchar temp[7]; //轉(zhuǎn)換后溫度存放變量

          //**************************************************
          //******************定義數(shù)據(jù)***********************
          //**************************************************
          //顯示: Temperature
          //顯示:WWW*PICAVR*COM
          const uchar name[16]=
          //{0x20,0x20,0x20,0x54,0x65,0x6d,0x70,0x65,0x72,0x61,0x74,0x75,0x72,0x65,0x20,0x20};
          {0x20,0x57,0x57,0x57,0x2E,0x50,0x49,0x43,0x41,0x56,0x52,0x2E,0x43,0x4F,0x4D,0x20};

          //***********************************************
          //函 數(shù) 名:delayms(uchar time);
          //入口參數(shù):time
          //出口參數(shù):無
          //函數(shù)作用:毫秒延時
          //說 明:
          //***********************************************
          void delayms(uchar time)
          {
          uint i;
          while(time--)
          {
          for(i=93;i>0;i--){;}
          }
          }

          //***********************************************
          //函 數(shù) 名:port_init();
          //入口參數(shù):無
          //出口參數(shù):無
          //函數(shù)作用:端口初始化
          //說 明:
          //***********************************************
          void port_init(void)
          {
          ADCON1=0X07; //設置RA,RE口為數(shù)字口
          TRISA=0X00; //設置RA口為輸出口
          TRISD=0X00; //設置RD口為輸出口
          TRISE=0X00; //設置RE口為輸出口
          OPTION=0X8F; //分頻給WDT,分頻比為128
          }

          //***********************************************
          //函 數(shù) 名:lcd_enable();
          //入口參數(shù):無
          //出口參數(shù):無
          //函數(shù)作用:LCD寫使能
          //說 明:
          //***********************************************
          void lcd_enable(void)
          {
          RS=0; //寫命令
          RW=0; //寫操作
          E=0; //低電平信號
          delayms(10); //低電平信號保持
          E=1; //拉高電平信號
          }

          //***********************************************
          //函 數(shù) 名:lcd_writebyte(uchar data);
          //入口參數(shù):data
          //出口參數(shù):無
          //函數(shù)作用:LCD寫一個字節(jié)數(shù)據(jù)
          //說 明:
          //***********************************************
          void lcd_writebyte(uchar data)
          {
          PORTD=data; //向RD口寫數(shù)據(jù)
          RS=1; //寫數(shù)據(jù)
          RW=0; //寫操作
          E=0; //低電平信號
          delayms(10); //低電平信號保持
          E=1; //拉高電平信號
          }

          //***********************************************
          //函 數(shù) 名:lcd_writedata(const uchar *ptt);
          //入口參數(shù):*ptt
          //出口參數(shù):無
          //函數(shù)作用:LCD寫數(shù)據(jù)塊函數(shù)
          //說 明:
          //***********************************************
          void lcd_writedata(const uchar *ptt)
          {
          uchar i;
          for(i=0;i<16;i++) //寫16個字節(jié)數(shù)據(jù)
          {
          lcd_writebyte(ptt); //查表寫數(shù)據(jù)
          }
          }


          上一頁 1 2 下一頁

          評論


          技術專區(qū)

          關閉