be80be
Well-Known Member
Here you a sample of using more then 1 temp sensors
Code:
Device = 18F4520
Clock = 8
Config OSC = INTIO67
// import modules...
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTD.2
#option LCD_EN = PORTD.3
// import modules...
Include "intio8" // you need to use this module to set the osccon you may
// Have one use its name mine uses that name
Include "DS18B20.bas"
Include "convert.bas"
Include "LCD.bas"
// on display temperature event...
Event OnDisplayTemp()
Dim TempA As ShortInt
Dim TempB As Word
Dim Index As Byte
RomID = SearchRomID
GetTemp(TempA, TempB)
LCD.Write(DecToStr(TempA),".",DecToStr(TempB,4),"C")
// display ROM ID...
LCD.Write(" ($")
Index = 6
Repeat
LCD.Write(HexToStr(SearchRomID(Index),2))
Dec(Index)
Until Index = 0
LCD.Write(")")
End Event
// program start...
SetPin(PORTC.0)
// if we have some DS1820 devices connected to the bus,
// then display temperature for each one...
If Count > 0 Then
While true
ConvertAll
FindAll(OnDisplayTemp)
DelayMS(1000)
Wend
EndIf
Last edited: