• Tidak ada hasil yang ditemukan

Rtc (Real Time Clock) Ds1307 Sebagai Pengatur Waktu Pada Sistem Traffic Light Adaptif

N/A
N/A
Protected

Academic year: 2017

Membagikan "Rtc (Real Time Clock) Ds1307 Sebagai Pengatur Waktu Pada Sistem Traffic Light Adaptif"

Copied!
11
0
0

Teks penuh

(1)

LAMPIRAN

(2)
(3)

LAMPIRAN

(4)

Program yang digunakan pada “RTC (Real Time Clock) DS1307 Sebagai Pengatur Waktu Pada Sistem Traffic Light Adaptif”

$regfile = "m8def.dat" $crystal = 16000000 $lib "ds1307clock.lib"

Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , Rs = Portc.5 , E = Portc.4

Config Lcd = 16 * 2 Cursor Off

Cls

Config Sda = Portd.7 Config Scl = Portd.6 Const Ds1307w = &HD0 Const Ds1307r = &HD1 Sqw Alias Pind.5

Tbl_menu Alias Pind.2 Tbl_up Alias Pind.3 Tbl_down Alias Pind.4 Pin_data Alias Portb.0

St_cp Alias Portb.1 'Enable

Sh_cp Alias Portb.2 'clock

Awal:

Enable Int0

Enable Interrupts On Int0 Set_waktu Dim Jam As Byte Dim Menit As Byte Dim Detik As Byte Dim Tunda As Byte Dim Temp As Byte

Dim Tunda_set As Byte Dim Slot As Byte

Dim Data1 As Byte Dim Data2 As Byte Locate 1 , 1

(5)

Locate 1 , 8

Gosub Ambil_waktu Gosub Cek_slot Gosub Tampil If Slot = 1 Then

Data1 = &H42 Data2 = &H42 Gosub Kirim_data Waitms 250

Data1 = 0 Data2 = 0

Gosub Kirim_data Waitms 250

Else

Gosub Looping_lampu End If

Loop

Kirim_data:

Shiftout Pin_data , Sh_cp , Data1 , 1 Shiftout Pin_data , Sh_cp , Data2 , 1 Set St_cp

Waitus 200 Reset St_cp Return

Ambil_waktu: I2cstart

I2cwbyte Ds1307w I2cwbyte 0

I2cstart

I2cwbyte Ds1307r I2crbyte Detik , Ack I2crbyte Menit , Ack I2crbyte Jam , Nack I2cstop

(6)

Incr Tunda End If

Temp = Detik Return

Tampil:

Locate 1 , 8 If Jam < 10 Then

Locate 1 , 8 Lcd "0"

End If Lcd Jam

Locate 1 , 11

If Menit < 10 Then Locate 1 , 11 Lcd "0"

End If Lcd Menit Locate 1 , 14

If Detik < 10 Then Locate 1 , 14 Lcd "0"

End If Lcd Detik Locate 2 , 14

If Tunda < 10 Then Locate 2 , 14 Lcd "0"

End If Lcd Tunda Locate 2 , 7 Lcd Slot Return

Set_waktu: Disable Int0 Waitms 250 Do

If Tbl_up = 0 Then Incr Menit

If Menit > 59 Then Menit = 0

(7)

End If

If Tbl_down = 0 Then Decr Menit

If Menit > 254 Then Menit = 59

End If Waitms 80 End If

Gosub Tampil Waitms 80

Loop Until Tbl_menu = 0 Waitms 150

Do

If Tbl_up = 0 Then Incr Jam

If Jam > 23 Then Jam = 0

End If Waitms 80 End If

If Tbl_down = 0 Then Decr Jam

If Jam > 254 Then Jam = 23

End If Waitms 80 End If

Gosub Tampil Waitms 80

Loop Until Tbl_menu = 0 Waitms 250

Detik = 0

Detik = Makebcd(detik) Menit = Makebcd(menit) Jam = Makebcd(jam) I2cstart

I2cwbyte Ds1307w I2cwbyte 0

I2cwbyte Detik I2cwbyte Menit I2cwbyte Jam I2cstop

(8)

Lcd "Waktu: " Locate 1 , 8 Lcd " : : " Locate 2 , 1

Lcd "Slot: Det: " Goto Awal

Return

Tunda_set = 5 End If

End If

If Jam >= 6 And Menit >= 0 Then If Jam <= 8 And Menit <= 59 Then

Slot = 3

Tunda_set = 15 End If

End If

If Jam >= 9 And Menit >= 0 Then

If Jam <= 11 And Menit <= 59 Then Slot = 4

Tunda_set = 10 End If

End If

If Jam >= 12 And Menit >= 0 Then If Jam <= 13 And Menit <= 59 Then

Slot = 5

Tunda_set = 15 End If

End If

If Jam >= 14 And Menit >= 0 Then If Jam <= 16 And Menit <= 59 Then

Slot = 6

(9)

End If

If Jam >= 17 And Menit >= 0 Then If Jam <= 20 And Menit <= 59 Then

Slot = 7

Tunda_set = 15 End If

End If

If Jam >= 21 And Menit >= 0 Then If Jam <= 23 And Menit <= 59 Then

Slot = 8

Tunda_set = 5 End If

End If

If Jam = 0 And Menit <= 59 Then Slot = 8

Tunda_set = 10 End If

Return

Looping_lampu: Data1 = &H24 Data2 = &H84 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = Tunda_set Tunda = 0

Data1 = &H44 Data2 = &H84 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = 2 Tunda = 0

Data1 = &H84 Data2 = &H24 Gosub Kirim_data Do

(10)

Gosub Tampil

Loop Until Tunda = Tunda_set Tunda = 0

Data1 = &H84 Data2 = &H44 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = 2 Tunda = 0

Data1 = &H81 Data2 = &H84 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = Tunda_set Tunda = 0

Data1 = &H82 Data2 = &H84 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = 2 Tunda = 0

Data1 = &H84 Data2 = &H81 Gosub Kirim_data Do

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = Tunda_set Tunda = 0

(11)

Gosub Ambil_waktu Gosub Tampil

Loop Until Tunda = 2 Tunda = 0

Referensi

Dokumen terkait

Panitia Pengdaan Barang/Jasa pada Dinas Kesehatan Kota Bandar Lampung akan melaksanakan Pelelangan Umum dengan pascakualifikasi untuk paket pekerjaan pengadaan

Kelompok Kerja ULP III di lingkungan Kantor Pusat Sekretariat Jenderal Kementerian Keuangan akan melaksanakan Pelelangan Sederhana dengan pascakualifikasi untuk paket

Panitia Pengdaan Barang/Jasa pada Dinas Kesehatan Kota Bandar Lampung akan melaksanakan Pelelangan Umum dengan pascakualifikasi untuk paket pekerjaan pengadaan

Sesi Nomor Absen 14973 LILLIS

Their possible biosynthetic precursor pyrrolidine-2-acetic acid and its methyl- ester were isolated and identi &#34; ed together with the pyrrolizidine alkaloids

Bangkok Bank Cabang Jakarta adalah kantor cabang dari Kantor Pusat Bangkok Bank di Thailand, dalam hal ini tidak ada informasi kepemilikan saham bank yang

Japanese Asplenium incisum also contained kaempferol 3- O -gentiobioside, but it was accompanied by kaempferol 3- O -gentiobioside-4 @ - O -glucoside, kaempferol 3- O - glucoside

Amina adalah senyawa organic yang mengandung atom nitrogen trivalent yang mengandung atom nitrogen trivalen yang berkaitan dengan satu atau dua atau tiga atom karbon, dimana amina