Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
If not DS18B20.Find Then
USART.Write("No device found", 13, 10)
Else
// 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
// 18F1320 @ 8MHz - they are just used here for clarity...
Device = 18F1220
Clock = 8
Config OSC=INTIO2
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.0
#option LCD_EN = PORTB.1
// import modules...
Include "INTOSC8"
Include "DS18B20.bas"
Include "LCD.bas"
Include "convert.bas"
Include "Utils"
// 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
DS18B20.SetPin(PORTA.4)
DelayMS (500)
LCD.Cls
// 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
WriteAt(1,1,"No device found")
Else
DelayMS(1000)
While true
DS18B20.Convert
DS18B20.GetTemp(TempA, TempB)
LCD.MoveCursor (2,1)
LCD.Write(DecToStr(TempA),".",DecToStr(TempB,4))
DelayMS(1000)
Wend
EndIf
Wend
// 18F1320 @ 8MHz - they are just used here for clarity...
Device = 18F1220
Clock = 8
Config OSC=INTIO2
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.0
#option LCD_EN = PORTB.1
// import modules...
Include "INTOSC8"
Include "DS18B20.bas"
Include "LCD.bas"
Include "convert.bas"
Include "Utils"
// 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
DS18B20.SetPin(PORTA.4)
DelayMS (500)
LCD.Cls
// 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
WriteAt(1,1,"No device found")
WriteAt(2,1,"We need One")
Else
DelayMS(1000)
While true
DS18B20.Convert
DS18B20.GetTemp(TempA, TempB)
LCD.MoveCursor (2,1)
LCD.Write(DecToStr(TempA),".C ",DecToStr(TempB),".C ")
DelayMS(1000)
Wend
EndIf
Wend
There is absolutely no difference in the accuracy of the DS18S20 and the DS18B20. They are both accurate to 0.5ºC.
Mike.
.
We don't need no claptrap software to reset usart pins.
I see over at that other site there are issues with the software usart.