全文预览

石油化工码头、库区消防安全管理规定

上传者:upcfxx |  格式:pdf  |  页数:10 |  大小:0KB

文档介绍
emp<=0x0800) { temp>>=4; //右移 4位, 相当于乘 0.0625 , 将温度化为十进制 temp*=10; //扩大 10 倍,显示一位小数 dis[0]=temp/1000; //千位 dis[1]=temp%1000/100; //百位 dis[2]=temp%1000%100/10; //十位 dis[3]=temp%1000%100%10; //个位} else { temp=~temp; temp+=1; temp>>=4; dis[0]=0x0c; //负数 dis[1]=temp%100/10; //百位 dis[2]=temp%100%10; //十位 dis[3]=0; //个位} P2=0x01; // 先片选,在段选,反过来就不能正常显示 P0=led[dis[0]]; delay(200); delay(200); P2=0x02; P0=led[dis[1]]; delay(200); delay(200); P2=0x04; P0=led1[dis[2]]; delay(200); delay(200); P2=0x08; P0=led[dis[3]]; delay(200); delay(200); } main() { unsigned char tl=0,th=0; while(1) { Init(); Write(); // 跳过读序号列号的操作 Write(0x44); // 启动温度转换 delay(100); Init(); Write(); // 跳过读序号列号的操作 Write(0xBE); // 读取温度寄存器等 delay(100); tl=Read(); // 读取温度值低位 th=Read(); // 读取温度值高位 temp=th<<8; temp|=tl; Display(temp); }}

收藏

分享

举报
下载此文档