BASIC stamp manual v2.2

OWIN – BASIC Stamp Command Reference
Page 302 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
SDEC tempC, " C ", CR,
SDEC tempF, " F "
PAUSE 1000
LOOP
END
Get_Temperature:
OWOUT DQ, 1, [SkipROM, CvrtTmp] ' send convert temperature command
DO ' wait on conversion
PAUSE 25 ' small loop pad
OWIN DQ, 4, [tempIn] ' check status (bit transfer)
LOOP UNTIL (tempIn) ' 1 when complete
OWOUT DQ, 1, [SkipROM, RdSP] ' read DS1822 scratch pad
OWIN DQ, 2, [tLo, tHi] ' get raw temp data
tSign = sign ' save sign bit
tempC = tempIn >> 4 ' round to whole degrees
tempC.BYTE1 = $FF * tSign ' correct twos complement bits
tempF = (ABS tempC) * 9 / 5 ' start F conversion
IF (tSign) THEN ' finish F conversion
tempF = 32 - tempF ' C was negative
ELSE
tempF = tempF + 32 ' C was positive
ENDIF
RETURN