Skip to main content

Jam Digital menggunakan Mikro ATMega8 dan Bahasa BASCOM-AVR

Jam Digital menggunakan Mikro ATMega8 dan Bahasa BASCOM-AVR
Belajar menggunakan LCD dengan ATMega8535 tidaklah sulit, dengan menggunakan bahasa Bascom AVR hal ini menjadi mudah dilakukan terutama bagi pemula. Berikut adalah rangkaian konfigurasi pin pada mikro ATMega8535 dan contoh program yang dapat dicoba. Selamat Mencoba.


Gambar Rangkaian :
Rangkaian Tampilan LCD.

Kode Bascom AVR

1 $regfile = "m8def.dat"
2 $crystal = 1000000
3 '------------------------ lcd -----------------------------------------------
4 Config Lcd = 16 * 2
5 Config Lcdpin = Pin , Rs = Pind.0 , E = Pind.1 , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5
6 Cls
7
8 '--------------------------- ds 1307 -----------------------------------------
9 $lib "ds1307clock.lib"
10 'configure the scl and sda pins
11 Config Sda = Portd.7
12 Config Scl = Portd.6
13 'address of ds1307
14 Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
15 Const Ds1307r = &HD1
16 '------------------------------ key --------------------------------------------
17 Config Pinc.1 = Input
18 Config Pinc.2 = Input
19 Config Pinc.3 = Input
20 Config Pinc.4 = Input
21 '------------------------------------------------------------------------------
22 Config Debounce = 30
23
24 Dim A As Byte , B As Byte , Data1 As Byte , C As Byte
25
26 Dim Seco As Byte , Mine As Byte , Hour As Byte
27
28 '----------------------------------------------------------------------------
29 Cursor Off
30 '-----------------------------
31 Cls
32 Locate 1 , 1
33 Lcd "Jam Digital LCD"
34 Locate 2 , 1
35 Lcd "Bina Project"
36 Wait 2

37
38 For A = 1 To 15
39 Shiftlcd Left
40 Waitms 30
41 Next
42
43 Cls
44 '-------------------------------------------------------------------------------
45 Main:
46 Do
47 Gosub Ds1307
48 Gosub 24_12
49 Gosub Chekkey
50
51 Loop
52 '-------------------------------------------------------------------------------
53 Ds1307:
54 I2cstart ' Generate start code
55 I2cwbyte Ds1307w ' send address
56 I2cwbyte 0 ' start address in 1307
57 I2cstart ' Generate start code
58 I2cwbyte Ds1307r ' send address
59 I2crbyte Seco , Ack 'sec
60 I2crbyte Mine , Ack ' MINUTES
61 I2crbyte Hour , Nack ' Hours
62 I2cstop
63
64 Seco = Makedec(seco) : Mine = Makedec(mine) : Hour = Makedec(hour)
65
66 If Seco > 59 Then Seco = 0
67 If Mine > 59 Then Mine = 0
68 If Hour > 23 Then
69 Hour = 0
70 Gosub Seco
71 End If

72
73 Return
74 '-------------------------------------------------------------------------------
75 24_12:
76 If Pinc.4 = 1 Then Gosub Disply_24
77 If Pinc.4 = 0 Then Gosub Disply_12
78 Return
79 '-------------------------------------------------------------------------------
80 Disply_24:
81
82 Locate 1 , 1
83 Lcd "Jam = " ; Hour ; ":" ;
84 If Mine < 10 Then 85 Lcd "0" ; Mine ; ":" ; 86 Else 87 Lcd Mine ; ":" ; 88 End If 89 90 If Seco < 10 Then 91 Lcd "0" ; Seco 92 Else 93 Lcd Seco 94 End If 95 96 Locate 2 , 6 97 Lcd "(24 Jam)" 98 99 Return 100 101 '------------------------------------------------------------------------------- 102 Disply_12: 103 104 If Hour = 0 Then Hour = 12 105 If Hour > 12 Then Hour = Hour - 12
106
107 Locate 1 , 1
108 Lcd "Jam = " ; Hour ; ":" ;
109 If Mine < 10 Then 110 Lcd "0" ; Mine ; ":" ; 111 Else 112 Lcd Mine ; ":" ; 113 End If 114 115 If Seco < 10 Then 116 Lcd "0" ; Seco 117 Else 118 Lcd Seco 119 End If 120 121 Locate 2 , 6 122 Lcd "(12 Jam)" 123 Return 124 '------------------------------------------------------------------------------- 125 Chekkey: 126 127 Debounce Pinc.1 , 0 , Seco , Sub 128 Debounce Pinc.2 , 0 , Mine , Sub 129 Debounce Pinc.3 , 0 , Hour , Sub 130 131 132 Return 133 '--------------------------------------------- 134 Seco: 135 Incr Seco 136 If Seco > 59 Then Seco = 0

137 Seco = Makebcd(seco)
138 I2cstart ' Generate start code
139 I2cwbyte Ds1307w ' send address
140 I2cwbyte 0 ' starting address in 1307
141 I2cwbyte Seco
142 I2cstop
143 Return
144
145 '-------------------------------------
146 Mine:

147 Incr Mine
148 If Mine > 59 Then Mine = 0
149 Mine = Makebcd(mine)
150 I2cstart ' Generate start code
151 I2cwbyte Ds1307w ' send address
152 I2cwbyte 1 ' starting address in 1307
153 I2cwbyte Mine
154 I2cstop
155 Return

Comments

Popular posts from this blog

74hc595 Shift Register

IC  74HC595   Arduino. penghematan pin arduino 74HC595  adalah IC ( integrated circuit , sirkuit elektronika terpadu) dari keluarga TTL seri 74 xx yang berfungsi sebagai  Shift Register . Kami menjual IC ini dalam 2 pilihan kemasan / packaging: versi DIP-16 ( Dual In-line Package  16 pin, 4 IC per paket) dan versi SMD ( Surface Mounted Device , 74HC595D, 5 IC per paket). Komponen elektronika ini memiliki register (kumpulan  flip-flop ) sepanjang 8-bit yang menerima masukan secara serial dan keluaran paralel dalam 8-pin keluaran. Data masukan disimpan pada register penyimpanan tipe-D sepanjang satu byte (8 bit D-type  storage register ). Gambar IC  74HC595   Gambar Schematic  74HC595   Di bawah ini adalah contoh rangkaiannya

Android 12 Developer Preview: Requirements, How to put in and more

  Hi-Jetniaga.com | Google has launched the primary Android 12 Developer Preview.  Here’s the whole lot you want to recognise approximately it, together with steps on the way to deployation it in your phone. oogle these days introduced its next-gen Android 12 running gadget, as a way to be released later this year.  The new running gadget will include numerous new functions, which intention to enhance the general overall performance and consumer experience.  Apart from the layout components, the agency is likewise introducing more than a few of  recent privateness functions, as a way to permit customers to govern how they’re tracked throughout sites.  You can test out the listing of the pinnacle five Android 12 functions right here.  Also Read – Twitter checking out Spaces for Android; in advance of March launch. The first developer preview for Android 12 is now available.  However, because of it being the primary developer preview take be aware t...

Arduino dan LCD

LCD (Liquid Crystal Display) adalah suatu jenis media tampilan yang menggunakan kristal cair sebagai penampil utama. LCD sudah digunakan di berbagai bidang, misalnya dalam alat-alat elektronik, seperti televisi, kalkulator ataupun layar komputer. Pada Percobaan kali ini adalah dengan menggunakan LCD 16x2 yang artinya LCD tersebut terdiri dari 16 kolom dan 2 baris karakter (tulisan). yang perlu di persiapkan adalah sebagai berikut LCD 16x2  Arduino UNO (Type Lain)  Kabel dan Konektor Berikut adalah pin dari LCD 16 X 2 No Kaki/Pin Nama Keterangan 1 VCC +5V 2 GND 0V 3 VEE Tegangan Kontras LCD 4 RS Register Select 5 R/W 1 = Read, 0 = Write 6 E Enable Clock LCD 7 D0 Data Bus 0 8 D1 Data Bus 1 9 D2 Data Bus 2 10 D3 Data Bus 3 11 D4 Data B...