ALAT UKUR JARAK DEPAN DAN BELAKANG MOBIL SAAT PARKIR
kali ini saya akan posting mengenai alat ukur jarak halangan pada bagian depan mobil dan belakang mobil yang biasanya diperlukan saat mobil akan parkir , pada alat ini menggunakan dua buah sensor jarak yaitu 2 buah ultrasonik hc-sr04 dan mikrokontroler yang digunakan yakni atmega8535.
bisa di;ihat pada skema dibawah ini bahwa alat ini berisikan 2 buah tombol push button yang berfungsi untuk, mengaktifkandan menonaktifkan mode pengukuran jarak serta berfungsi untuk mengatur jarak yang dianggap keadaan hati- hati dan keadaan yang dianggap berhaya (stop).
terdapat 1buah buzzer dan berisikan 3buah warna led yang berbeda untuk indikator yang difungsikan untuk memberitahukan si pengemudi bahwa keadaan depan atau belakang mobil dalam keadaan hati-hati maupun keadaan harus stop.dan dilengkapi sebuah lcd 2x16 yang difungsikan untuk menampilkan jarak halangan yang berada di depan ataupun di belakang mobil.
skema alat ukur jarak mobil saat parkir
rangkaian ini cukup sederhana, dimana kalian yang ingin membuatnya tidak akan terlalu kesulitan dalam membuat layoutnya karena tidak bnyak terdapat komponen2 pada rangkaian ini. dibawah ini adaah contoh layout dari rangkaian alat ukur jarak mobil yang saya buat menggunakan software eagle.
ini testing videonya
PROGRAM DENGAN BASCOM AVR
$regfile = "8535def.dat"
$crystal = 16000000
Config Portd = Output
'************************************ SWICTH ***********************************
Config Pina.5 = Input
Config Pina.6 = Input
Tombol1 Alias Pina.6
Tombol2 Alias Pina.5
'*******************lampu indikator
Config Portc.0 = Output
Config Portc.1 = Output
Config Portd.7 = Output
Led_hijau Alias Portd.7
Led_kuning Alias Portc.0
Led_merah Alias Portc.1
Led_merah = 0
Led_hijau = 0
Led_kuning = 0
Buzzer Alias Portd.0
Config Timer1 = Timer , Prescale = 64
Config Pina.1 = Input
Config Pina.3 = Input
Config Porta.2 = Output
Config Porta.4 = Output
Echoo1 Alias Pina.1
Trigger1 Alias Porta.2
Echoo2 Alias Pina.3
Trigger2 Alias Porta.4
Dim Data_timer1 As Integer , Data_timer2 As Integer
Dim Data_timer_depan As Single , Data_timer_belakang As Single
Dim Jarak_depan As String * 6 , Jarak_belakang As String * 6
Dim Nilai_hati2 As Byte , Nilai_stop As Byte
Dim S_nilai_hati2 As Single , S_nilai_stop As Single
'****************************** CONFIGURASI PORT LCD *******
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.3 , Db6 = Portd.2 , Db7 = Portd.1 , E = Portd.5 , Rs = Portd.6
Config Lcd = 16 * 2 : Cursor Off
'************************* CONFIGURASI ADC *****************
Config Adc = Single , Prescaler = Auto
'*************************************************************
Cls
Readeeprom Nilai_hati2 , 3
Readeeprom Nilai_stop , 6
Menu:
Cls
Locate 1 , 4 : Lcd "<< MENU >>"
Lowerline
Lcd "SET DETEK"
Do
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Gosub Setting
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Waitms 300
Goto Deteksi
End If
Loop
Deteksi:
S_nilai_hati2 = Nilai_hati2
S_nilai_stop = Nilai_stop
Cls
Do
Gosub Data_depan
Gosub Data_belakang
Locate 1 , 1
Data_timer_depan = Data_timer1 / 14
Jarak_depan = Fusing(data_timer_depan , "##.#")
'Lcd Jarak_depan ; " CM "
Locate 2 , 1
Data_timer_belakang = Data_timer2 / 14
Jarak_belakang = Fusing(data_timer_belakang , "##.#")
'Lcd Jarak_belakang ; " CM "
If Data_timer_depan < Data_timer_belakang Then
Locate 1 , 10 : Lcd Jarak_depan ; " CM "
Gosub Peringatan_depan
Else
Locate 1 , 10 : Lcd Jarak_belakang ; " CM "
Gosub Peringatan_belakang
End If
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Gosub Menu
End If
Loop
'*********************************************************************
'*********************************************************************
Peringatan_depan:
If Data_timer_depan > S_nilai_hati2 Then
Led_merah = 0
Led_hijau = 1
Led_kuning = 0
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "aman "
End If
If Data_timer_depan <= S_nilai_hati2 And Data_timer_depan > S_nilai_stop Then
Led_merah = 0
Led_hijau = 0
Led_kuning = 1
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "hati-hati"
Sound Buzzer , 200 , 700
Waitms 500
End If
If Data_timer_depan <= S_nilai_stop Then
Led_merah = 1
Led_hijau = 0
Led_kuning = 0
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "behenti "
Sound Buzzer , 1000 , 700
End If
Return
'*********************************************************************
'*********************************************************************
Peringatan_belakang:
If Data_timer_belakang > S_nilai_hati2 Then
Led_merah = 0
Led_hijau = 1
Led_kuning = 0
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "aman "
End If
If Data_timer_belakang <= S_nilai_hati2 And Data_timer_belakang > S_nilai_stop Then
Led_merah = 0
Led_hijau = 0
Led_kuning = 1
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "hati-hati "
Sound Buzzer , 200 , 700
Waitms 500
End If
If Data_timer_belakang <= S_nilai_stop Then
Led_merah = 1
Led_hijau = 0
Led_kuning = 0
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "berhenti "
Sound Buzzer , 1000 , 700
End If
Return
Data_depan:
Set Trigger1
Waitus 10
Reset Trigger1
Bitwait Echoo1 , Set
Data_timer1 = 0
Timer1 = 0
Start Timer1
Do
If Echoo1 = 0 Then
Data_timer1 = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer1 = 0
Exit Do
End If
Loop
Stop Timer1
Return
Data_belakang:
Set Trigger2
Waitus 10
Reset Trigger2
Bitwait Echoo2 , Set
Data_timer2 = 0
Timer1 = 0
Start Timer1
Do
If Echoo2 = 0 Then
Data_timer2 = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer2 = 0
Exit Do
End If
Loop
Stop Timer1
Return
Setting:
Cls
Locate 1 , 1 : Lcd " jarak hati-hati "
Do
Locate 2 , 2 : Lcd "jarak=" ; Nilai_hati2 ; " CM "
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Writeeeprom Nilai_hati2 , 3
Exit Do
End If
If Tombol2 = 0 Then
Waitms 200
Incr Nilai_hati2
If Nilai_hati2 > 100 Then Nilai_hati2 = 0
End If
Loop
Cls
Locate 1 , 1 : Lcd " jarak stop "
Do
Locate 2 , 2 : Lcd "jarak=" ; Nilai_stop ; " CM "
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Writeeeprom Nilai_stop , 6
Exit Do
End If
If Tombol2 = 0 Then
Waitms 200
Incr Nilai_stop
If Nilai_stop > 100 Then Nilai_stop = 0
End If
Loop
Cls
Locate 3 , 1 : Lcd "selesai"
Wait 1
Goto Menu
Return
$crystal = 16000000
Config Portd = Output
'************************************ SWICTH ***********************************
Config Pina.5 = Input
Config Pina.6 = Input
Tombol1 Alias Pina.6
Tombol2 Alias Pina.5
'*******************lampu indikator
Config Portc.0 = Output
Config Portc.1 = Output
Config Portd.7 = Output
Led_hijau Alias Portd.7
Led_kuning Alias Portc.0
Led_merah Alias Portc.1
Led_merah = 0
Led_hijau = 0
Led_kuning = 0
Buzzer Alias Portd.0
Config Timer1 = Timer , Prescale = 64
Config Pina.1 = Input
Config Pina.3 = Input
Config Porta.2 = Output
Config Porta.4 = Output
Echoo1 Alias Pina.1
Trigger1 Alias Porta.2
Echoo2 Alias Pina.3
Trigger2 Alias Porta.4
Dim Data_timer1 As Integer , Data_timer2 As Integer
Dim Data_timer_depan As Single , Data_timer_belakang As Single
Dim Jarak_depan As String * 6 , Jarak_belakang As String * 6
Dim Nilai_hati2 As Byte , Nilai_stop As Byte
Dim S_nilai_hati2 As Single , S_nilai_stop As Single
'****************************** CONFIGURASI PORT LCD *******
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.3 , Db6 = Portd.2 , Db7 = Portd.1 , E = Portd.5 , Rs = Portd.6
Config Lcd = 16 * 2 : Cursor Off
'************************* CONFIGURASI ADC *****************
Config Adc = Single , Prescaler = Auto
'*************************************************************
Cls
Readeeprom Nilai_hati2 , 3
Readeeprom Nilai_stop , 6
Menu:
Cls
Locate 1 , 4 : Lcd "<< MENU >>"
Lowerline
Lcd "SET DETEK"
Do
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Gosub Setting
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Waitms 300
Goto Deteksi
End If
Loop
Deteksi:
S_nilai_hati2 = Nilai_hati2
S_nilai_stop = Nilai_stop
Cls
Do
Gosub Data_depan
Gosub Data_belakang
Locate 1 , 1
Data_timer_depan = Data_timer1 / 14
Jarak_depan = Fusing(data_timer_depan , "##.#")
'Lcd Jarak_depan ; " CM "
Locate 2 , 1
Data_timer_belakang = Data_timer2 / 14
Jarak_belakang = Fusing(data_timer_belakang , "##.#")
'Lcd Jarak_belakang ; " CM "
If Data_timer_depan < Data_timer_belakang Then
Locate 1 , 10 : Lcd Jarak_depan ; " CM "
Gosub Peringatan_depan
Else
Locate 1 , 10 : Lcd Jarak_belakang ; " CM "
Gosub Peringatan_belakang
End If
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Gosub Menu
End If
Loop
'*********************************************************************
'*********************************************************************
Peringatan_depan:
If Data_timer_depan > S_nilai_hati2 Then
Led_merah = 0
Led_hijau = 1
Led_kuning = 0
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "aman "
End If
If Data_timer_depan <= S_nilai_hati2 And Data_timer_depan > S_nilai_stop Then
Led_merah = 0
Led_hijau = 0
Led_kuning = 1
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "hati-hati"
Sound Buzzer , 200 , 700
Waitms 500
End If
If Data_timer_depan <= S_nilai_stop Then
Led_merah = 1
Led_hijau = 0
Led_kuning = 0
Locate 1 , 1 : Lcd "depan "
Locate 2 , 1 : Lcd "behenti "
Sound Buzzer , 1000 , 700
End If
Return
'*********************************************************************
'*********************************************************************
Peringatan_belakang:
If Data_timer_belakang > S_nilai_hati2 Then
Led_merah = 0
Led_hijau = 1
Led_kuning = 0
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "aman "
End If
If Data_timer_belakang <= S_nilai_hati2 And Data_timer_belakang > S_nilai_stop Then
Led_merah = 0
Led_hijau = 0
Led_kuning = 1
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "hati-hati "
Sound Buzzer , 200 , 700
Waitms 500
End If
If Data_timer_belakang <= S_nilai_stop Then
Led_merah = 1
Led_hijau = 0
Led_kuning = 0
Locate 1 , 1 : Lcd "belakang"
Locate 2 , 1 : Lcd "berhenti "
Sound Buzzer , 1000 , 700
End If
Return
Data_depan:
Set Trigger1
Waitus 10
Reset Trigger1
Bitwait Echoo1 , Set
Data_timer1 = 0
Timer1 = 0
Start Timer1
Do
If Echoo1 = 0 Then
Data_timer1 = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer1 = 0
Exit Do
End If
Loop
Stop Timer1
Return
Data_belakang:
Set Trigger2
Waitus 10
Reset Trigger2
Bitwait Echoo2 , Set
Data_timer2 = 0
Timer1 = 0
Start Timer1
Do
If Echoo2 = 0 Then
Data_timer2 = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer2 = 0
Exit Do
End If
Loop
Stop Timer1
Return
Setting:
Cls
Locate 1 , 1 : Lcd " jarak hati-hati "
Do
Locate 2 , 2 : Lcd "jarak=" ; Nilai_hati2 ; " CM "
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Writeeeprom Nilai_hati2 , 3
Exit Do
End If
If Tombol2 = 0 Then
Waitms 200
Incr Nilai_hati2
If Nilai_hati2 > 100 Then Nilai_hati2 = 0
End If
Loop
Cls
Locate 1 , 1 : Lcd " jarak stop "
Do
Locate 2 , 2 : Lcd "jarak=" ; Nilai_stop ; " CM "
If Tombol1 = 0 Then
Cls
Bitwait Tombol1 , Set
Waitms 100
Writeeeprom Nilai_stop , 6
Exit Do
End If
If Tombol2 = 0 Then
Waitms 200
Incr Nilai_stop
If Nilai_stop > 100 Then Nilai_stop = 0
End If
Loop
Cls
Locate 3 , 1 : Lcd "selesai"
Wait 1
Goto Menu
Return
halo gan untuk diagram blok rangkainnya ada nggak ?
ReplyDeletemaaf gan, boleh saya minta email nya? sekedar sharing. project akhir saya pengukur jarak kendaraan berbasis atmega8535
ReplyDeleteMaf admin, saya pengen nannya. Programnya apa ya,trus pakai software apa?
ReplyDelete