// 18F1320 @ 8MHz - they are just used here for clarity...
Device = 18F1220
Clock = 8
Config OSC=INTIO2
// import modules...
Include "INTOSC8"
Include "DS18B20.bas"
Include "convert.bas"
Include "Utils"
Include "usart.bas"
// working variables...
Dim
TempA As ShortInt,
TempB As Word
// program start...
ADCON1 = $7f //all digital
TRISA.3=0 //A3 output
PORTA.3=1 //and high
USART.SetBaudrate(br9600)
DS18B20.SetPin(PORTA.4)
// Find() will search the bus for a single DS1820 device
// and load its ROM ID into the DS1820 public variable RomID - you
// could do this manually. For example, RomID = MyRomID...
While true
DelayMS(100)
If not DS18B20.Find Then
USART.Write("No device found", 13, 10)
Else
DelayMS(1000)
While true
DS18B20.Convert
DS18B20.GetTemp(TempA, TempB)
USART.Write(DecToStr(TempA),".",DecToStr(TempB,4), $BA, "C", 13, 10)
DelayMS(1000)
Wend
EndIf
Wend