文档介绍:DS18B20的详细使用方法DS18B20概述
DS18B20数字温度计是DALLAS公司生产的1—Wire,即单总线器件,具有线路简单, 体积小的特点。因此用它来组成一个测温系统,具有线路简单,在一根通信线,可以挂很多 这样的数字温度计
S5
24
S4
23
S3
22
S2
21
SI
DQ
AT89S51
Y1 00 X A 6 O 二 z12MHz=j=C7 C6130P. 30p
GNDDS18B20与AT89C2051组成的测温系统源程序
用一片DS18B20构成测温系统,,测 量的温度的范围在一20度到+ 1 00度之间,用8位数码管显示出来。
下面是采用AT89C205 1单片机与DS18B20的测温系统C语言源程 序,硬件电路请参考本站相关文章.
# I Nclude <># I Nclude <INTRINS. II>Unsigned Char Code Displaybit[]={Oxfe,Oxfd,Oxfb,0xf7,Oxef, Oxdf, Oxbf, 0 x 7 f);
Unsigned Char Code Displaycode[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07,
0x7f, 0x6f, 0x77, 0 x 7 c, 0x39, Ox5e, 0x79, 0x7 1, 0x00, 0x40};Unsigned Char Code Dotcode[32] = {0, 3, 6, 9, 12, 16, 19, 22, 25,28,31,34,38,41,44,48, 50,53,56,59,63,66,69,72, 75, 78,81, 84, 88, 91, 94, 97};
Unsigned CharDi splaycount;
Unsigned Char Di splaybuf [8] = {16, 1 6, 16, 1 6, 1 6, 1 6, 1 6, 1 6};Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Char Timecount;Char Readdata [8];Sbit DQ = P3^7 ;Bit Sf1ag;
Bit Resetpulse (Void)
Unsigned Char I;
DQ = O ;
For (1 = 255; I>0 ; I--);
DQ = 1 ;
For (1 = 60;I>0;I--);
Return (DQ);
For (1 = 200;I>0;I--);
Void Writecommandtodsl8b20 (Unsigned Char Command)
Unsigned Char I;
Uns i gned Char J;
For (1 = 0;I<8;I+ + )If ( (Command & 0x01)= = 0)For (J = 35;J>0;J--);DQ=1 ;
)Else(DQ = 0 ;
For (J = 2;J>0;J--);DQ=1 ;For (J = 33;J>0;J--);}
Command =