DS18B20測溫程序
2015-5-12 10:49:00??????點擊:
如有疑問聯系客服,(程序下載在低端)程序開頭如下:
#include "reg52.h"
#include "intrins.h"#define uchar unsigned char
#define uint unsigned int
sbit ds=P2^2;
sbit dula=P2^6;
sbit wela=P2^7;
uchar flag ;
uint temp; //參數temp一定要聲明為 int 型
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //不帶小數點數字編碼
uchar code table1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,
0x87,0xff,0xef}; //帶小數點數字編碼
/*延時函數*/
void TempDelay (uchar us)
{
while(us--);
}
void delay(uint count) //延時子函數
{
uint i;
while(count)
{
i=200;
while(i>0)
i--;
count--;
}
}
更多優質傳感器來自永陽新能源: PT100 http://www.disf.com.cn
文件下載:20150512105022481.rar (點擊即可下載)
- 上一篇:單法蘭液位變送器使用常識 2015/5/13
- 下一篇:熱電偶的常用結構普及 2015/5/11