ds18b20 c程序
//DS1820 C51 子程序
//這里以11.0592M晶體為例, 不同的晶體速度可能需要調整延時的時間
//sbit DQ =P2^1;//根據實際情況定義端口
typedef unsigned char byte;
typedef unsigned int word;
//延時
void delay(word useconds)
{
for(;useconds>0;useconds--);
}
//復位
byte ow_reset(void)
{
byte presence;
DQ = 0; //pull DQ line low
delay(29); // leave it low for 480us
DQ = 1; // allow line to return high
delay(3); // wait for presence
presence = DQ; // get presence signal
delay(25); // wait for end of timeslot
return(presence); // presence signal returned
} // 0=presence, 1 = no part
//從 1-wire 總線上讀取一個字節
byte read_byte(void)
{
byte i;
byte value = http://www.byf.com/baike/0;
for (i=8;i>0;i--)
{
value>>=1;
DQ = 0; // pull DQ low to start timeslot
DQ = 1; // then return high
delay(1); //for (i=0; i<3; i++);
if(DQ)value|=0
- 白糖的功效與作用 很多人都不知道,趕緊收藏起來吧!
- 與男生網上搭訕技巧 搭訕男生也需要用心
- 兒童保健 小兒風疹的預防與調護
- SED1335與51單片機的接口程序設計
- 肉盒子的面怎么和才軟?
- 羊蛋的功效與作用
- KTV約會攻略,如何在KTV與女生甜蜜互動
- 心機 屬兔與屬猴能不能合作
- AR與VR技術應用到美妝與零售行業
- 三合冷焊機與氬弧焊有什么不同
