Kod: Zaznacz cały
$crystal = 4000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5
Config Lcdpin = Pin , Db6 = Portb.6 , Db7 = Portb.7
Config 1wire = Pinb.0
Config Pinb.0 = Output
Config Pinb.1 = Output
Declare Sub Odczyt
Dim Temperatura(2) As Byte
Deflcdchar 0 , 254 , 242 , 242 , 254 , 224 , 224 , 224 , 224
Cursor Off
Do
Call Odczyt
Cls
If Temperatura(2) = 0 Then
Lcd "temp:" ; Chr(0) ; Temperatura(1) ; Chr(0) ; "C"
Print "temp:" ; Chr(0) ; Temperatura(1) ; Chr(248) ; "C"
If Temperatura(1) > 28 Then
Set Portb.0
Reset Portb.1
Else
Reset Portb.0
Set Portb.1
End If
Else
Lcd "temp:-" ; Chr(0) ; Temperatura(1) ; Chr(0) ; "C"
Print "temp:-" ; Chr(0) ; Temperatura(1) ; Chr(248) ; "C"
End If
Loop
End
Sub Odczyt
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 750
1wreset
1wwrite &HCC
1wwrite &HBE
Temperatura(1) = 1wread(3)
If Temperatura(2) > 0 Then
Temperatura(1) = 256 - Temperatura(1)
End If
Temperatura(1) = Temperatura(1) / 2
End Sub