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 - 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库51单片机温度计 - 图文(5)在线全文阅读。
相关推荐: