#in cludereg51.h
#in clude intrin s.h
#include math.H //要用到取绝对值函数 abs()
//通过DS18B20测试当前环境温度,并通过数码管显示当前温度值,目前显示范围:-55~
+125 度
sbit wela = P2A7; // 数码管位选
sbit dula =卩2人6; //数码管段选
sbit ds = P2A2; |
int tempValue;
〃0-F数码管的编码(共阳极)
un sig ned char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
〃0-9数码管的编码(共阳极),带小数点
unsigned char code tableWidthDot[]={0x40, 0x79, 0x24, 0x30,
0x19, 0x12, 0x02,0x78, 0x00, 0x10};
〃延时函数,对于11.0592MHz 时钟,例i=10,则大概延时10ms.
void delay (un sig ned int i)
{
un sig ned int j;
while(i--)
for(j = 0; j 125; j++);
//初始化DS18B20
II让DS1
原创力文档

文档评论(0)