-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atmega16 + 16x2 Character lcd display.bas
174 lines (145 loc) · 2.72 KB
/
Atmega16 + 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
'======================================================================='
' Title: LCD Display Clock * Calendar
' Last Updated : 04.2022
' Author : A.Hossein.Khalilian
' Program code : BASCOM-AVR 2.0.8.5
' Hardware req. : Atmega16 + 16x2 Character lcd display
'======================================================================='
$regfile = "m16def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db7 = Porta.0 , Db6 = Porta.1 , Db5 = Porta.2 , Db4 = Porta.3 , E = Porta.4 , Rs = Porta.5
Config Debounce = 30
Config Clock = Soft
Config Date = Ymd , Separator = /
Dim T As Byte , D As Byte
T = 0
D = 0
Enable Interrupts
Time$ = "23:59:50"
Date$ = "22/12/31"
Cursor Off
Cls
'-----------------------------------------------------------
Do
Home
Lcd "Time: " ; Time$
Lowerline
Lcd "Date: " ; Date$
Debounce Pinb.0 , 0 , Menu
Repeat:
Loop
End
'-----------------------------------------------------------
Menu:
T = 0
D = 0
Cls
Lcd "1-Time Setting"
Do
Debounce Pinb.0 , 0 , Label1
Debounce Pinb.1 , 0 , Timeset
Loop
''''''''''''''''''''''''''''''
Label1:
Cls
Lcd "2-Date Setting"
Do
Debounce Pinb.0 , 0 , Repeat
Debounce Pinb.1 , 0 , Dateset
Loop
''''''''''''''''''''''''''''''
Timeset:
Cls
Incr T
Lcd "Hour: " ; _hour
Do
Debounce Pinb.1 , 0 , Inctime , Sub
Debounce Pinb.0 , 0 , Label2
Loop
''''''''''''''''''''''''''''''
Label2:
Cls
Incr T
Lcd "Min: " ; _min
Do
Debounce Pinb.1 , 0 , Inctime , Sub
Debounce Pinb.0 , 0 , Label1
Loop
''''''''''''''''''''''''''''''
Dateset:
Cls
Incr D
Lcd "Day: " ; _day
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Label3
Loop
''''''''''''''''''''''''''''''
Label3:
Cls
Incr D
Lcd "Month: " ; _month
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Label4
Loop
''''''''''''''''''''''''''''''
Label4:
Cls
Incr D
Lcd "Year: " ; _year
Do
Debounce Pinb.1 , 0 , Incdate , Sub
Debounce Pinb.0 , 0 , Repeat
Loop
''''''''''''''''''''''''''''''
Inctime:
If T = 1 Then
Incr _hour
If _hour = 24 Then
_hour = 0
End If
Cls
Lcd "Hour: " ; _hour
Else
If T = 2 Then
Incr _min
If _min = 60 Then
_min = 0
End If
Cls
Lcd "Min: " ; _min
End If
End If
Return
''''''''''''''''''''''''''''''
Incdate:
If D = 1 Then
Incr _day
If _day > 31 Then
_day = 1
End If
Cls
Lcd "Day: " ; _day
Else
If D = 2 Then
Incr _month
If _month > 12 Then
_month = 1
End If
Cls
Lcd "Month: " ; _month
Else
If D = 3 Then
Incr _year
If _year > 100 Then
_year = 0
End If
Cls
Lcd "Year: " ; _year
End If
End If
End If
Return
'-----------------------------------------------------------