51单片机温度计 - 图文(5)

2019-08-29 00:05

else wendu_L++;

}

if(SHOW==2) {

if(wendu_H<99)

wendu_H++;

} } if(!K3) {

delay(100); if(SHOW==0)return; if(SHOW==1) {

if(wendu_L>0)

wendu_L--;

}

if(SHOW==2) {

if(wendu_H==(wendu_L+1))

return;

- 13 -

}

else wendu_H--;

} }

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

// uchar i;

Sys_Initial();//单片机初始化,开定时器0 while(1) {

wendu_read();

mun=wendu*10+xiaoshu;

if(wendu>wendu_L&&wendu

jingbao=0; } else jingbao=1; key_scan();

- 14 -

}

}

//DS18B20的最底层函数。 sbit DS=P3^6;

#define uchar unsigned char uchar tempL=0xaa; uchar tempH=0x50; uchar wendu,xiaoshu;

//------------------------------------------------- void delay1(uchar count) {

while(count>0) count--; }

void reset(void) //send reset and initialization command { DS=0; delay1(100); DS=1; delay1(4); delay1(20); }

- 15 -

//温度传感器传回来的温度低八位 //温度传感器传回来的温度高八位

bit read_bit(void) //read a bit {

bit temp; DS=0; _nop_(); DS=1; _nop_(); temp=DS;

EA=1;

delay1(20);

EA=0;

return temp; }

uchar read_byte(void) {

uchar i,byte=0; bit j;

for(i=0;i<8;i++) {

//read a byte date - 16 -

byte=_cror_(byte ,1); j=read_bit();

if(j==0) byte=byte|0x00; else byte=byte|0x80; }

return byte; }

void write_byte(uchar command) //write a byte to ds18b20 { uchar i; for(i=0;i<8;i++) {

if((command & 0x01)==0) { DS=0; delay1(8); DS=1; _nop_(); } else {

- 17 -


51单片机温度计 - 图文(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:80浮头换热器毕业设计-说明书2 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: