Appendix Aplikasi Sensor Air Hujan dan LDR (Light Dependent Resistor) Untuk Alat Pengering Kopi Otomatis Berbasis ATMega 8
LAMPIRAN 1. FOTO ALAT YANG SUDAH JADI DAN BEKERJA
DENGAN BAIK
59
60
LAMPIRAN 2. GAMBAR LENGKAP PENGERING KOPI OTOMATIS
61
LAMPIRAN 3 .LISTING PROGRAM SISTEM KERJA ALAT
KESELURUHAN.
Progam
$regfile = "m8def.dat"
$crystal = 16000000
Config Lcd = 16x2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.1 , Db6 = Portc.0 , Db7 = Portb.2
, E = Portc.3 , Rs = Portc.4
Cursor Off
Config Adc = Free , Prescaler = Auto , Reference = Avcc
Start Adc
Tbl1 Alias Pind.0
Tbl2 Alias Pind.1
Tbl3 Alias Pind.2
Sensor_air Alias Pind.3
Limbuka Alias Pind.4
Limtutup Alias Pinb.1
M1 Alias Portd.6
M2 Alias Portd.7
V Alias Portd.5
Lampu Alias Portb.0
Dim Dataadc As Word
Dim Dataset As Word
62
Dim Modealat As Bit
Dim Posisi As Bit
Dim Air As Bit
Dim Com_pintu As Bit
Dim Com_relay As Bit
Enable Int0
Enable Interrupts
On Int0 Setting_mode
Dataset = 500
Set Com_pintu
Set Com_relay
Gosub Buka
Awal:
Cls
Gosub Tampilan
Do
Gosub Auto
If Tbl2 = 0 Then
Waitms 150
Gosub Manual
End If
Waitus 20
63
Loop
Auto:
Modealat = 1
Dataadc = Getadc(5)
If Dataadc > Dataset And Sensor_air = 1 Then
'Cuaca Cerah
Gosub Buka
End If
If Dataadc Dataset And Sensor_air = 0 Then
'Cerah hujan
Gosub Tutup
End If
Gosub Update
Return
Update:
Air = Sensor_air
Dataadc = Getadc(5)
Locate 1 , 6
Lcd "
"
Locate 1 , 7
If Modealat = 1 Then
64
Lcd "A"
Else
Lcd "M"
End If
Locate 1 , 16
Lcd " "
Locate 1 , 16
If Posisi = 1 Then
Lcd "O"
Else
Lcd "C"
End If
Locate 2 , 6
Lcd " "
Locate 2 , 6
Lcd Dataadc
Locate 2 , 16
Lcd " "
Locate 2 , 16
Lcd Sensor_air
Return
Tampilan:
Locate 1 , 1
65
Lcd "
"
Locate 1 , 1
Lcd "Mode:
Door: "
Locate 2 , 1
Lcd "
"
Locate 2 , 1
Lcd "ADC :
Air : "
Return
Buka:
Posisi = 1
If Limbuka = 1 Then
Do
Gosub Update
Set M1
Reset M2
Toggle V
Waitms 50
Loop Until Limbuka = 0
End If
Reset Lampu
Reset M1
Reset M2
Reset V
Return
Tutup:
66
Posisi = 0
If Limtutup = 1 Then
Do
Gosub Update
Reset M1
Set M2
Toggle V
Waitms 50
Loop Until Limtutup = 0
End If
Set Lampu
Reset M1
Reset M2
Reset V
Return
Setting_mode:
Disable Int0
Disable Interrupts
Waitms 150
Cls
Locate 1 , 1
Lcd " Setting Data "
Waitms 500
Cls
67
Locate 1 , 1
Lcd "ADC: "
Locate 2 , 1
Lcd "Set: "
Do
Dataadc = Getadc(5)
If Tbl1 = 0 Then
Incr Dataset
Waitms 80
End If
If Tbl2 = 0 Then
Decr Dataset
Waitms 80
End If
Locate 1 , 5
Lcd "
"
Locate 1 , 5
Lcd Dataadc
Locate 2 , 5
Lcd "
"
Locate 2 , 5
Lcd Dataset
Waitms 80
Loop Until Tbl3 = 0
Waitms 150
68
Enable Int0
Enable Interrupts
Goto Awal
Return
Manual:
Disable Int0
Disable Interrupts
Modealat = 0
Do
If Tbl1 = 0 Then
Toggle Com_pintu
Waitms 20
End If
If Tbl3 = 0 Then
Toggle Com_relay
Waitms 20
End If
If Com_pintu = 1 Then
Gosub Buka
Else
Gosub Tutup
End If
If Com_relay = 1 Then
69
Set Lampu
Else
Reset Lampu
End If
Gosub Update
Waitms 100
Loop Until Tbl2 = 0
Waitms 150
Enable Int0
Enable Interrupts
Return
70
DENGAN BAIK
59
60
LAMPIRAN 2. GAMBAR LENGKAP PENGERING KOPI OTOMATIS
61
LAMPIRAN 3 .LISTING PROGRAM SISTEM KERJA ALAT
KESELURUHAN.
Progam
$regfile = "m8def.dat"
$crystal = 16000000
Config Lcd = 16x2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.1 , Db6 = Portc.0 , Db7 = Portb.2
, E = Portc.3 , Rs = Portc.4
Cursor Off
Config Adc = Free , Prescaler = Auto , Reference = Avcc
Start Adc
Tbl1 Alias Pind.0
Tbl2 Alias Pind.1
Tbl3 Alias Pind.2
Sensor_air Alias Pind.3
Limbuka Alias Pind.4
Limtutup Alias Pinb.1
M1 Alias Portd.6
M2 Alias Portd.7
V Alias Portd.5
Lampu Alias Portb.0
Dim Dataadc As Word
Dim Dataset As Word
62
Dim Modealat As Bit
Dim Posisi As Bit
Dim Air As Bit
Dim Com_pintu As Bit
Dim Com_relay As Bit
Enable Int0
Enable Interrupts
On Int0 Setting_mode
Dataset = 500
Set Com_pintu
Set Com_relay
Gosub Buka
Awal:
Cls
Gosub Tampilan
Do
Gosub Auto
If Tbl2 = 0 Then
Waitms 150
Gosub Manual
End If
Waitus 20
63
Loop
Auto:
Modealat = 1
Dataadc = Getadc(5)
If Dataadc > Dataset And Sensor_air = 1 Then
'Cuaca Cerah
Gosub Buka
End If
If Dataadc Dataset And Sensor_air = 0 Then
'Cerah hujan
Gosub Tutup
End If
Gosub Update
Return
Update:
Air = Sensor_air
Dataadc = Getadc(5)
Locate 1 , 6
Lcd "
"
Locate 1 , 7
If Modealat = 1 Then
64
Lcd "A"
Else
Lcd "M"
End If
Locate 1 , 16
Lcd " "
Locate 1 , 16
If Posisi = 1 Then
Lcd "O"
Else
Lcd "C"
End If
Locate 2 , 6
Lcd " "
Locate 2 , 6
Lcd Dataadc
Locate 2 , 16
Lcd " "
Locate 2 , 16
Lcd Sensor_air
Return
Tampilan:
Locate 1 , 1
65
Lcd "
"
Locate 1 , 1
Lcd "Mode:
Door: "
Locate 2 , 1
Lcd "
"
Locate 2 , 1
Lcd "ADC :
Air : "
Return
Buka:
Posisi = 1
If Limbuka = 1 Then
Do
Gosub Update
Set M1
Reset M2
Toggle V
Waitms 50
Loop Until Limbuka = 0
End If
Reset Lampu
Reset M1
Reset M2
Reset V
Return
Tutup:
66
Posisi = 0
If Limtutup = 1 Then
Do
Gosub Update
Reset M1
Set M2
Toggle V
Waitms 50
Loop Until Limtutup = 0
End If
Set Lampu
Reset M1
Reset M2
Reset V
Return
Setting_mode:
Disable Int0
Disable Interrupts
Waitms 150
Cls
Locate 1 , 1
Lcd " Setting Data "
Waitms 500
Cls
67
Locate 1 , 1
Lcd "ADC: "
Locate 2 , 1
Lcd "Set: "
Do
Dataadc = Getadc(5)
If Tbl1 = 0 Then
Incr Dataset
Waitms 80
End If
If Tbl2 = 0 Then
Decr Dataset
Waitms 80
End If
Locate 1 , 5
Lcd "
"
Locate 1 , 5
Lcd Dataadc
Locate 2 , 5
Lcd "
"
Locate 2 , 5
Lcd Dataset
Waitms 80
Loop Until Tbl3 = 0
Waitms 150
68
Enable Int0
Enable Interrupts
Goto Awal
Return
Manual:
Disable Int0
Disable Interrupts
Modealat = 0
Do
If Tbl1 = 0 Then
Toggle Com_pintu
Waitms 20
End If
If Tbl3 = 0 Then
Toggle Com_relay
Waitms 20
End If
If Com_pintu = 1 Then
Gosub Buka
Else
Gosub Tutup
End If
If Com_relay = 1 Then
69
Set Lampu
Else
Reset Lampu
End If
Gosub Update
Waitms 100
Loop Until Tbl2 = 0
Waitms 150
Enable Int0
Enable Interrupts
Return
70