RSS

Membuat Jam Digital yang dilengkapai dengan Setting Atmega Bascom AVR

24 Mar

Membuat program Jam digital dengan Mikrokontroler Bahasa Bascom ternyata tidak sulit. Bagi temen temen Elektromania ini mungkin bermanfaan bagi anda, ada contoh sederhana memebuat jam digital dengan dilengkapi setting jam dan tanggal

Gambar rangkaian :

Gambar rangkaian dengan Simulator Proteus

Kode Program dengan Bascom (Bas)
2 $regfile = "m8def.dat"
3 $crystal = 1000000
4 $hwstack = 40
5 $swstack = 20
6 $framesize = 32 
8 Declare Sub Actual()  9 
10 Config Lcd = 16 * 4
11 Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.0 , Rs = Portd.1 12 Config Lcdbus = 4 13 Deflcdchar Print , 14 , 32 , 17 , 25 , 21 , 19 , 17 , 17
14 Config Date = Dmy , Separator = /
15 Config Clock = Soft
16 Enable Interrupts 17 
18 Dim Minuto As Byte 19  20 
21 Ddrd.2 = 1 : Portd.2 = 0
22 Ddrc.0 = 0 : Portc.0 = 1
23 Ddrc.1 = 0 : Portc.1 = 1 24 
25 Tombol_select Alias Pinc.0
26 Tombol_set Alias Pinc.1 27  28 
29 Date$ = "23/03/11"
30 Time$ = "00:00:00"
31 Minuto = _min 32 
33 Cls 34 Cursor Off 35 
36 Awal:
37    Locate 1 , 1 : Lcd "BINA ELEKTRONIKA"
38    Locate 3 , 1 : Lcd "JAM :"
39    Locate 2 , 1 : Lcd "TGL :"
40    Locate 4 , 1 : Lcd "         "
42 Awal1:
44    If Tombol_select = 0 Then 45 
46       Waitms 5
47       Bitwait Tombol_select , Set
48       Goto Seting_detik 49 
50    End If 51  52    Call Actual
53    Goto Awal1 54  55 Seting_detik: 56 
57    Locate 4 , 1 : Lcd "SET DETIK" 58 
59 Seting_detik1: 60 
61    If Tombol_select = 0 Then
62 
63       Waitms 5
64       Bitwait Tombol_select , Set
65       Goto Seting_menit 66 
67    End If 68 
69    If Tombol_set = 0 Then 70 
71       Waitms 5 72       _sec = 0
73       Bitwait Tombol_set , Set 74 
75    End If 76  77    Call Actual 78    Goto Seting_detik1 79 
80  81 Seting_menit: 82  83    Locate 4 , 1 : Lcd "SET MENIT " 84  85 Seting_menit1: 86  87    If Tombol_select = 0 Then 88  89       Waitms 5 90       Bitwait Tombol_select , Set 91       Goto Seting_jam 92  93    End If 94  95    If Tombol_set = 0 Then 96  97       Waitms 5 98       Incr _min 99       If _min = 60 Then100          _min = 0101       End If102       Bitwait Tombol_set , Set103 104    End If105 106    Call Actual107    Goto Seting_menit1108 109 Seting_jam:110 111    Locate 4 , 1 : Lcd "SET JAM  "112 113 Seting_jam1:114 115    If Tombol_select = 0 Then116 117       Waitms 5118       Bitwait Tombol_select , Set119       Goto Seting_hari120 121    End If122 123    If Tombol_set = 0 Then124 125       Waitms 5126       Incr _hour127       If _hour = 24 Then128          _hour = 0129       End If130       Bitwait Tombol_set , Set131 132    End If133 134    Call Actual135    Goto Seting_jam1136 137 Seting_hari:138 139    Locate 4 , 1 : Lcd "SET TANGGAL  "140 141 Seting_hari1:142 143    If Tombol_select = 0 Then144 145       Waitms 5146       Bitwait Tombol_select , Set147       Goto Seting_bulan148 149    End If150 151    If Tombol_set = 0 Then152 153       Waitms 5154       Incr _day155       If _day = 32 Then156          _day = 1157       End If158       Bitwait Tombol_set , Set159 160    End If161 162    Call Actual163    Goto Seting_hari1164 165 Seting_bulan:166 167    Locate 4 , 1 : Lcd "SET BULAN  "168 169 Seting_bulan1:170 171    If Tombol_select = 0 Then172 173       Waitms 5174       Bitwait Tombol_select , Set175       Goto Seting_tahun176 177    End If178 179    If Tombol_set = 0 Then180 181       Waitms 5182       Incr _month183       If _month = 13 Then184          _month = 1185       End If186       Bitwait Tombol_set , Set187 188    End If189 190    Call Actual191    Goto Seting_bulan1192 193 194 Seting_tahun:195 196    'Locate 4 , 1 : Lcd "A"197    'Locate 4 , 2 : Lcd Chr(0)198    Locate 4 , 1 : Lcd "SET TAHUN  "199 200 Seting_tahun1:201 202    If Tombol_select = 0 Then203 204       Waitms 5205       Bitwait Tombol_select , Set206       Goto Awal207 208    End If209 210    If Tombol_set = 0 Then211 212       Waitms 5213       Incr _year214       If _year = 100 Then215          _year = 00216       End If217       Bitwait Tombol_set , Set218 219    End If220 221    Call Actual222    Goto Seting_tahun1223 224 225 Actual:226 227    Locate 2 , 7 : Lcd Date$228    Locate 3 , 7 : Lcd Time$229    If _min <> Minuto Then230 231       Minuto = _min232       Toggle Portd.2233 234    End If235 236 Return237 238 End
 
Tinggalkan komentar

Ditulis oleh pada Kamis, Maret 24, 2011 in Mikrokontroler

 

Jangan Lupa Tinggalkan Komentar Anda !

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: