【文件属性】:
文件名称:18B20温度检测,单片机
文件大小:3KB
文件格式:C
更新时间:2014-07-04 09:55:54
18B20温度检测
#include
#define uchar unsigned char
#define uint unsigned int
sbit DS=P2^7; //define interface 定义接口
uint temp; // variable of temperature 定义一个变量用来表示温度
uchar flag1; // sign of the result positive or negative 定义一个标志,标志温度是否还是正
sbit P2_0=P2^0; //数码管位选
sbit P2_1=P2^1;
sbit P2_2=P2^2;
unsigned char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82, //数字编码
0xf8,0x80,0x90};
unsigned char code table1[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02, //带小数点的编码
0x78,0x00,0x10};
void delay(uint count) //delay 延时子程序
{
uint i;
while(count)
{
i=200;
while(i>0)
i--;
count--;
}
}