Kod: Zaznacz cały
Config Lcd = 16 * 2
Dim S As Byte
Dim H As Byte , G As Byte
H = 2 'histereza
S = 20
P3 = 255
Config 1wire = P1.0 'use P1,0 for 1wire communication
Deflcdchar 0 , 14 , 10 , 14 , 32 , 32 , 32 , 32 , 32
Dim Temp_buf As Byte , Tmp As Byte , T1 As Integer , T2 As Integer
Dim Ar(9) As Byte , I As Byte , T As Integer
'Cursor Off Noblink
Cls
Wait 3
Tem:
Do
Cls
Lcd "T set=" ; S
Set P3.0
Set P3.1
Set P3.2
Waitms 250
Waitms 100
If P3.0 = 0 Then S = S + 1
If P3.1 = 0 Then S = S - 1
If P3.2 = 0 Then Exit Do
Loop
' histereza
Do
Cls
Lcd "h=" ; H
Set P3.0
Set P3.1
Set P3.2
Waitms 250
Waitms 100
If P3.0 = 0 Then H = H + 1
If P3.1 = 0 Then H = H - 1
If P3.2 = 0 Then Exit Do
Loop
' end
Cls
Set P3.2
Main:
1wreset
1wwrite &HCC
1wwrite &H44
1wreset
Gosub Pause
Citaj:
1wreset
1wwrite &HCC
1wwrite &HBE
For I = 1 To 9
Temp_buf = 1wread()
Ar(i) = Temp_buf
Next
1wreset
'precision 0.1 C
Tmp = Ar(1) And 1
If Tmp = 1 Then
Decr Ar(1)
End If
T = Makeint(ar(1) , Ar(2))
T = T * 50 : T = T - 25 : T1 = Ar(8) - Ar(7) : T1 = T1 * 100
T1 = T1 / Ar(8) : T = T + T1 : T = T / 10
T1 = T
T = T / 10
T2 = T * 10
T1 = T1 - T2
'T=temperature in C,T1= 1/10C
Ispis:
'--------------------------------- write on lcd DISPLAY ----------------------------------------------
If T < 0 Then
Locate 1 , 4 : Lcd "-"
Else
Locate 1 , 4 : Lcd " "
End If
T = Abs(t)
If T > 99 Then
Locate 1 , 5
Elseif T > 9 Then
Locate 1 , 6
Elseif T < 10 Then
Locate 1 , 7
End If
Lcd T ; "." ; T1
Locate 1 , 11 : Lcd Chr(0) : Locate 1 , 12 : Lcd "C"
Locate 2 , 1 : Lcd "T set=" ; S
If P3.2 = 0 Then Goto Tem
G = S - H
If T >= S Then
Reset P3.3
Elseif T < G Then
Set P3.3
End If
Goto Main
Pause:
Waitms 250
Return
End