基于单片机的无线多路数据(温度)采集系统的设计与实现毕业论文 联系客服

发布时间 : 星期日 文章基于单片机的无线多路数据(温度)采集系统的设计与实现毕业论文更新完毕开始阅读6528d75c69d97f192279168884868762caaebb38

#include”ds18b20.h” #define uchar unsigned char

/***********pt2262发射函数***********/ void send_dat(uchar x) {

uchar x1,x2; x1=x&0x0f;

P2=x1;//将数据的低4位先发送出去 x2=x>>4;

P2=x2;//再将数据的高4位发送出去 }

/************主函数******************/ void main() {

while(1) {

read_ds18b20();//读取温度 send_dat(temp1);//发射温度1

send_dat(temp2);//发射温度2 send_dat(temp3);//发射温度3

} }

Ds18b20.h头文件: #ifndef _ds18b20

#define _ds18b20

uchar temperature,y1,y2,x2,y3; #define DQ P1_0 //温度接收口 uchar tpl; uchar tph;

/************************************************************/ void delay_b(uint t) {

uint i;

while(t--) {

for(i=0;i<125;i++); } }

/************************************************************/ void txreset(void) {

uint i; DQ=0; i=100;

while(i>0) i--; DQ=1; i=4;

while(i>0) i--;

}

/************************************************************/ void rxwait(void)

{ uint i;

while(DQ);

/************************************************************/ bit rdbit(void)

{ uint i; bit b; DQ=0; i++; DQ=1; i++;i++; b=DQ; i=8; while(i>0) i--; while(!DQ); i=4;

while(i>0) i--; }

return (b); }

/************************************************************ *Function:读18B20的一个字节

*************************************************************/ uchar rdbyte(void)

{

uchar i,j,b; for(i=1;i<=8;i++)

{

}

return (b); }

j=rdbit(); b=(j<<7) | (b>>1);

/************************************************************ *Function:向18B20写入一个字节

*************************************************************/ void wrbyte(uchar b) {

uint i;

uchar j, btm;

for(j=1; j<=8;j++)

{