Kod: Zaznacz cały
Config 1wire = P1.0
Config Lcd = 16 * 2
Deflcdchar 0 , 238 , 234 , 238 , 224 , 224 , 224 , 224 , 224
Dim Is_device As Bit
Dim Number(8) As Byte
Dim T(2) As Byte
Dim X As Byte
Dim R As Byte
Dim Temp As Single
Dim Str_temp As String * 5
Const R_rom = &H33
Const Con_t = &H44
Const M_rom = &H55
Const R_src = &HBE
' Komunikaty
Const Kom_1 = "Termometr "
Const Kom_2 = "Temp. :"
Const Minus = "-"
Const Celcj = "C"
Const Err_1 = "blad: "
Const Err_2 = "brak lacza !"
'Deklaracje procedur
Declare Sub Read_numbers
Declare Sub Pomiar_temp
Declare Sub Match_rom
Declare Sub Wysw_temp
Declare Sub 1w_reset
Cls
Is_device = 1
Cursor Off
Lcd Kom_1
Wait 1
Cls
Cursor Off
Lcd Kom_2
Do
1w_reset
If Err = 1 Then
Is_device = 0
Cls
Lcd Err_1 ; Err_2
Waitms 250
Else
Call Read_numbers
Call Pomiar_temp
Call Wysw_temp
End If
Loop
Sub Read_numbers
If Is_device = 0 Then
Cls
Lcd Kom_2
Is_device = 1
End If
1wwrite R_rom
For R = 1 To 8
Number(r) = 1wread()
Next R
End Sub
Sub Pomiar_temp
1w_reset
Call Match_rom
1wwrite Con_t
Waitms 250
Waitms 250
1w_reset
Call Match_rom
1wwrite R_src
T(1) = 1wread()
T(2) = 1wread()
1w_reset
End Sub
Sub Match_rom
1wwrite M_rom
For R = 1 To 8
1wwrite Number(r)
If Err = 1 Then
Is_device = 0
Cls
Lcd Err_1 ; R
Wait 1
End If
Next R
End Sub
Sub Wysw_temp
Locate 2 , 2
If T(2) = 0 Then
Temp = T(1) / 2
Else
X = 256 - T(1)
Temp = X / 2
Lcd Minus
End If
Str_temp = Fusing(temp , ###.&)
Lcd Str_temp ; Chr(0) ; Celcj ; " "
End Sub
Sub 1w_reset
1wreset
End Sub
Kod: Zaznacz cały
, ps. nie wysmiewamy za niewiedze. [/color]