-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atmega32 + DS18B20 + 16x2 Character lcd display.bas
98 lines (73 loc) · 2.19 KB
/
Atmega32 + DS18B20 + 16x2 Character lcd display.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
'======================================================================='
' Title: LCD Display Thermometer * Multiple Sensors
' Last Updated : 05.2022
' Author : A.Hossein.Khalilian
' Program code : BASCOM-AVR 2.0.8.5
' Hardware req. : Atmega32 + DS18B20 + 16x2 Character lcd display
'======================================================================='
$regfile = "m32def.dat"
$crystal = 1000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.2 , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2
Cursor Off
Cls
Config 1wire = Porta.0
Dim Temperature As String * 6
Dim Buffer_digital As Integer
Dim Ds18b20_id_1(9) As Byte
Dim Ds18b20_id_2(8) As Byte
Dim Ds18b20_id_3(8) As Byte
Dim Ds18b20_id_4(8) As Byte
Deflcdchar 0 , 232 , 244 , 232 , 227 , 228 , 228 , 227 , 224
Ds18b20_id_1(1) = 1wsearchfirst()
Ds18b20_id_2(1) = 1wsearchnext()
Ds18b20_id_3(1) = 1wsearchnext()
Ds18b20_id_4(1) = 1wsearchnext()
Cls
Locate 1 , 1 : Lcd " Thermometer"
Locate 2 , 1 : Lcd " ------------------"
Wait 2
Cls
Waitms 500
'------------------------------------------------------
Do
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 750
1wreset
1wwrite &H55
1wverify Ds18b20_id_1(1)
1wwrite &HBE
Buffer_digital = 1wread(2)
Gosub Conversion
Locate 1 , 1 : Lcd "1:" ; Temperature ; Chr(0)
1wreset
1wwrite &H55
1wverify Ds18b20_id_2(1)
1wwrite &HBE
Buffer_digital = 1wread(2)
Gosub Conversion
Locate 1 , 9 : Lcd "2:" ; Temperature ; Chr(0)
1wreset
1wwrite &H55
1wverify Ds18b20_id_3(1)
1wwrite &HBE
Buffer_digital = 1wread(2)
Gosub Conversion
Locate 2 , 1 : Lcd "3:" ; Temperature ; Chr(0)
1wreset
1wwrite &H55
1wverify Ds18b20_id_4(1)
1wwrite &HBE
Buffer_digital = 1wread(2)
Gosub Conversion
Locate 2 , 9 : Lcd "4:" ; Temperature ; Chr(0)
Loop
End
'--------------------------------------------
Conversion:
Buffer_digital = Buffer_digital * 10 : Buffer_digital = Buffer_digital \ 16
Temperature = Str(buffer_digital) : Temperature = Format(temperature , "0.0")
Return
'--------------------------------------------