Seperti video yang ditayangkan diatas, alat yang akan dibuat adalah alat yang digunakan untuk mendeteksi apakah lampu rusak atau tidak, sebenarnya ini adalah simulasi dari lampu penerangan jalan yang mana jika ada lampu yang rusak maka akan mengirimkan pesan berupa sms, lampu penerang jalan ini jika malam hari akan hidup namun pada pagi hari akan mati namun jika malam hari lampu tidak menyala, entah itu karena ada rusak lampu atau rusak komponen maka akan ada info yang memberitahukannya melalui sms. untuk membuat alat ini sangatlah mudah yaitu memerlukan sebuah minimum system ATMega plus LCD, sensor Photodioda, sensor LDR, Tombol 3 buah dan rangkaian serial RS232
1. Minimum System ATMega8
2. Skematik System
3. Program Bascom AVR
$regfile = "m8def.dat"
$crystal = 12000000
$baud = 9600
Config Lcdpin = Pin , Rs = Portd.6 , E = Portd.5 , Db4 = Portd.3
Config Lcdpin = Pin , Db5 = Portd.2 , Db6 = Portb.4 , Db7 = Portb.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Ddrd.4 = 1
Ddrd.7 = 1
Led Alias Portd.4
Lampu Alias Portd.7
Tombol1 Alias Pinb.0
Tombol2 Alias Pinb.1
Tombol3 Alias Pinb.2
Set Portb.0
Set Portb.1
Set Portb.2
Dim Nilaildr As Word
Dim Dataldr As Eram Word
Dim Ldr As Word
Dim Ldrbyte As Byte
Dim Photo As Word
Dim Hp As String * 30
Hp = "08562951773"
Cls
Cursor Off
Start Adc
'malam = LDR < 30
'pagi = ldr > 30
'lampu mati > 900
'lampu hidup < 900
Do
Ldr = Getadc(0)
Locate 1 , 1
Lcd "LDR= " ; Ldr
Locate 2 , 1
Lcd "Photo= " ; Photo
'malam
If Ldr < Dataldr Then
Lampu = 1
'pagi
Elseif Ldr > Dataldr Then
Lampu = 0
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Goto Aturldr
End If
Waitms 300
Photo = Getadc(1)
'untuk deteksi kerusakan
If Ldr < Dataldr And Photo > 900 Then
'sms
Goto Sms
Else
'tidak sms
Led = 0
End If
Loop
Aturldr:
Cls
Nilaildr = 0
Do
Upperline
Lcd "Batas Malam"
Lowerline
Lcd "LDR= " ; Nilaildr ; " "
If Tombol1 = 0 Then
Incr Nilaildr
Waitms 50
If Nilaildr > 1000 Then
Nilaildr = 0
End If
End If
If Tombol3 = 0 Then
Decr Nilaildr
Waitms 50
If Nilaildr < 0 Then
Nilaildr = 1000
End If
End If
If Tombol2 = 0 Then
Dataldr = Nilaildr
Bitwait Tombol2 , Set
Exit Do
End If
Waitms 50
Loop
Return
Sms:
Do
Photo = Getadc(1)
Print "AT+CMGS=" ; Hp
Wait 1
Print "Lampu Rusak"
Print Chr(26)
Wait 1
Led = 1
Wait 60
Photo = Getadc(1)
Loop Until Photo < 900
Return
$crystal = 12000000
$baud = 9600
Config Lcdpin = Pin , Rs = Portd.6 , E = Portd.5 , Db4 = Portd.3
Config Lcdpin = Pin , Db5 = Portd.2 , Db6 = Portb.4 , Db7 = Portb.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Ddrd.4 = 1
Ddrd.7 = 1
Led Alias Portd.4
Lampu Alias Portd.7
Tombol1 Alias Pinb.0
Tombol2 Alias Pinb.1
Tombol3 Alias Pinb.2
Set Portb.0
Set Portb.1
Set Portb.2
Dim Nilaildr As Word
Dim Dataldr As Eram Word
Dim Ldr As Word
Dim Ldrbyte As Byte
Dim Photo As Word
Dim Hp As String * 30
Hp = "08562951773"
Cls
Cursor Off
Start Adc
'malam = LDR < 30
'pagi = ldr > 30
'lampu mati > 900
'lampu hidup < 900
Do
Ldr = Getadc(0)
Locate 1 , 1
Lcd "LDR= " ; Ldr
Locate 2 , 1
Lcd "Photo= " ; Photo
'malam
If Ldr < Dataldr Then
Lampu = 1
'pagi
Elseif Ldr > Dataldr Then
Lampu = 0
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Goto Aturldr
End If
Waitms 300
Photo = Getadc(1)
'untuk deteksi kerusakan
If Ldr < Dataldr And Photo > 900 Then
'sms
Goto Sms
Else
'tidak sms
Led = 0
End If
Loop
Aturldr:
Cls
Nilaildr = 0
Do
Upperline
Lcd "Batas Malam"
Lowerline
Lcd "LDR= " ; Nilaildr ; " "
If Tombol1 = 0 Then
Incr Nilaildr
Waitms 50
If Nilaildr > 1000 Then
Nilaildr = 0
End If
End If
If Tombol3 = 0 Then
Decr Nilaildr
Waitms 50
If Nilaildr < 0 Then
Nilaildr = 1000
End If
End If
If Tombol2 = 0 Then
Dataldr = Nilaildr
Bitwait Tombol2 , Set
Exit Do
End If
Waitms 50
Loop
Return
Sms:
Do
Photo = Getadc(1)
Print "AT+CMGS=" ; Hp
Wait 1
Print "Lampu Rusak"
Print Chr(26)
Wait 1
Led = 1
Wait 60
Photo = Getadc(1)
Loop Until Photo < 900
Return
Pesan Alat seperti diatas sms ke no. 085726496643 (Yanuar)
atau Email = Yanuarm@hotmail.com
No comments:
Post a Comment