Pada kesempatan yang berbahagia kali ini saya akan menjelaskan mengenai bagaimana membuat alat untuk mengukur tinggi atau jarak dan berat badan dengan output suara, alat ini sebenarnya diperuntukkan bagi tuna netra yang ingin mengukur berat dan dan tinggi tubuhnya, karena jika menggunakan tampilan display tidak bisa terbaca maka harus menggunakan suara. Alat ini menggunakan beberapa komponen utama yaitu LCD 16x4, loadcell 200kg, modul perekam suara ISD1420, sensor jarak PING dan minimum system ATMega8535. untuk lebih jelasnya berikut program dan skemanya.
Register input suara
0 - se
10 - satu
20 - dua
30 - tiga
40 - empat
50 - lima
60 - enam
70 - tujuh
80 - delapan
90 - sembilan
100 - ratus
110 - puluh
120 - belas
130 - berat
140 - tinggi
150 - kilogram
b. Sensor Jarak PING)))
c. Sensor Berat ( Load Cell )
d. Modul Record Suara ISD1420
e. Driver Relay 5v
f. Program Bascom AVR ( ISI REGISTER ISD1420 )
$regfile = "m8535.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Timer , Prescale = 64
Sigout Alias Portc.7
Sigin Alias Pinc.7
Dirsig Alias Ddrc.7
Dim Data_timer As Integer
Dim Ratusan As Integer
Dim Puluhan As Integer
Dim Satuan As Integer
Dim Temp As Integer
Dim Ratusan1 As Integer
Dim Puluhan1 As Integer
Dim Satuan1 As Integer
Dim Temp1 As Integer
Dim Dataadc As Word
Dim A As Integer
A = 0
Ddrd = &B11111111
Ddrb = &B00000000
Portb = &B11111111
Cls
Cursor Off
Start Adc
Do
Dataadc = Getadc(0)
Portd = A
Locate 1 , 1
Lcd "Berat = " ; Dataadc ; " kg"
Locate 2 , 1
Lcd "Tinggi = " ; Data_timer ; " cm"
Locate 3 , 1
Lcd "Reg = " ; A
If Pinb.0 = 0 Then
Waitms 200
A = A + 10
Elseif Pinb.1 = 0 Then
Waitms 200
A = A - 10
Elseif Pinb.2 = 0 Then
Waitms 200
End If
Gosub Ambil_datatimer
Data_timer = Data_timer / 10
Waitms 100
Loop
Ambil_datatimer:
Dirsig = 1
Set Sigout
Waitus 10
Reset Sigout
Dirsig = 0
Set Sigout
Bitwait Sigin , Set
Data_timer = 0
Timer1 = 0
Start Timer1
Do
If Sigin = 0 Then
Data_timer = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer = 0
Exit Do
End If
Loop
Stop Timer1
Return
g. Program Bascom AVR ( Output Suara )
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Timer , Prescale = 64
Sigout Alias Portc.7
Sigin Alias Pinc.7
Dirsig Alias Ddrc.7
Dim Data_timer As Integer
Dim Ratusan As Integer
Dim Puluhan As Integer
Dim Satuan As Integer
Dim Temp As Integer
Dim Ratusan1 As Integer
Dim Puluhan1 As Integer
Dim Satuan1 As Integer
Dim Temp1 As Integer
Dim Dataadc As Word
Dim A As Integer
A = 0
Ddrd = &B11111111
Ddrb = &B00000000
Portb = &B11111111
Cls
Cursor Off
Start Adc
Do
Dataadc = Getadc(0)
Portd = A
Locate 1 , 1
Lcd "Berat = " ; Dataadc ; " kg"
Locate 2 , 1
Lcd "Tinggi = " ; Data_timer ; " cm"
Locate 3 , 1
Lcd "Reg = " ; A
If Pinb.0 = 0 Then
Waitms 200
A = A + 10
Elseif Pinb.1 = 0 Then
Waitms 200
A = A - 10
Elseif Pinb.2 = 0 Then
Waitms 200
End If
Gosub Ambil_datatimer
Data_timer = Data_timer / 10
Waitms 100
Loop
Ambil_datatimer:
Dirsig = 1
Set Sigout
Waitus 10
Reset Sigout
Dirsig = 0
Set Sigout
Bitwait Sigin , Set
Data_timer = 0
Timer1 = 0
Start Timer1
Do
If Sigin = 0 Then
Data_timer = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer = 0
Exit Do
End If
Loop
Stop Timer1
Return
g. Program Bascom AVR ( Output Suara )
$regfile = "m8535.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Timer , Prescale = 64
Declare Sub Regratusan
Declare Sub Regpuluhan
Declare Sub Regsatuan
Declare Sub Belakang
Sigout Alias Portc.7
Sigin Alias Pinc.7
Dirsig Alias Ddrc.7
Dim Data_timer As Integer
Dim Ratusan As Integer
Dim Puluhan As Integer
Dim Satuan As Integer
Dim Temp As Integer
Dim Ratusan1 As Integer
Dim Puluhan1 As Integer
Dim Satuan1 As Integer
Dim Temp1 As Integer
Dim Dataadc As Word
Dim A As Integer
Dim X As Integer
A = 0
X = 350
Ddrb.3 = 1
Ddrd = &B11111111
Cls
Cursor Off
Start Adc
Do
Dataadc = Getadc(0)
Locate 1 , 1
Lcd "Berat = " ; Dataadc ; " kg"
Locate 2 , 1
Lcd "Tinggi = " ; Data_timer ; " cm"
Gosub Ambil_datatimer
Data_timer = Data_timer / 10
Waitms 100
Temp = Dataadc
'Mencari angka Ratusan
Ratusan = Temp / 100
'Mencari angka Puluhan
Temp = Temp Mod 100
Puluhan = Temp / 10
'Mencari angka Satuan
Satuan = Temp Mod 10
Temp1 = Data_timer
'Mencari angka Ratusan
Ratusan1 = Temp1 / 100
'Mencari angka Puluhan
Temp1 = Temp1 Mod 100
Puluhan1 = Temp1 / 10
'Mencari angka Satuan
Satuan1 = Temp1 Mod 10
Portd = 130
Portb.3 = 0
Waitms x
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
If Ratusan = 1 Then
A = 0
Call Regratusan
Elseif Ratusan = 2 Then
A = 20
Call Regratusan
Elseif Ratusan = 3 Then
A = 30
Call Regratusan
Elseif Ratusan = 4 Then
A = 40
Call Regratusan
Elseif Ratusan = 5 Then
A = 50
Call Regratusan
Elseif Ratusan = 6 Then
A = 60
Call Regratusan
Elseif Ratusan = 7 Then
A = 70
Call Regratusan
Elseif Ratusan = 8 Then
A = 80
Call Regratusan
Elseif Ratusan = 9 Then
A = 90
Call Regratusan
End If
If Puluhan = 1 And Satuan = 1 Then
Portd = 0
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 120
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Elseif Puluhan = 1 And Satuan = 0 Then
Portd = 0
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 110
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Elseif Puluhan = 2 Then
A = 20
Call Regpuluhan
Elseif Puluhan = 3 Then
A = 30
Call Regpuluhan
Elseif Puluhan = 4 Then
A = 40
Call Regpuluhan
Elseif Puluhan = 5 Then
A = 50
Call Regpuluhan
Elseif Puluhan = 6 Then
A = 60
Call Regpuluhan
Elseif Puluhan = 7 Then
A = 70
Call Regpuluhan
Elseif Puluhan = 8 Then
A = 80
Call Regpuluhan
Elseif Puluhan = 9 Then
A = 90
Call Regpuluhan
End If
If Satuan = 1 And Puluhan <> 1 Then
A = 10
Call Regsatuan
Elseif Satuan = 2 Then
A = 20
Call Regsatuan
Elseif Satuan = 3 Then
A = 30
Call Regsatuan
Elseif Satuan = 4 Then
A = 40
Call Regsatuan
Elseif Satuan = 5 Then
A = 50
Call Regsatuan
Elseif Satuan = 6 Then
A = 60
Call Regsatuan
Elseif Satuan = 7 Then
A = 70
Call Regsatuan
Elseif Satuan = 8 Then
A = 80
Call Regsatuan
Elseif Satuan = 9 Then
A = 90
Call Regsatuan
End If
If Puluhan = 1 And Satuan <> 0 And Satuan <> 1 Then
Portd = 120
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
End If
Portd = 150
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Waitms 500
Portd = 140
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
If Ratusan1 = 1 Then
A = 0
Call Regratusan
Elseif Ratusan1 = 2 Then
A = 20
Call Regratusan
Elseif Ratusan1 = 3 Then
A = 30
Call Regratusan
Elseif Ratusan1 = 4 Then
A = 40
Call Regratusan
Elseif Ratusan1 = 5 Then
A = 50
Call Regratusan
Elseif Ratusan1 = 6 Then
A = 60
Call Regratusan
Elseif Ratusan1 = 7 Then
A = 70
Call Regratusan
Elseif Ratusan1 = 8 Then
A = 80
Call Regratusan
Elseif Ratusan1 = 9 Then
A = 90
Call Regratusan
End If
If Puluhan1 = 1 And Satuan1 = 1 Then
Portd = 0
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 120
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Elseif Puluhan1 = 1 And Satuan1 = 0 Then
Portd = 0
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 110
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Elseif Puluhan1 = 2 Then
A = 20
Call Regpuluhan
Elseif Puluhan1 = 3 Then
A = 30
Call Regpuluhan
Elseif Puluhan1 = 4 Then
A = 40
Call Regpuluhan
Elseif Puluhan1 = 5 Then
A = 50
Call Regpuluhan
Elseif Puluhan1 = 6 Then
A = 60
Call Regpuluhan
Elseif Puluhan1 = 7 Then
A = 70
Call Regpuluhan
Elseif Puluhan1 = 8 Then
A = 80
Call Regpuluhan
Elseif Puluhan1 = 9 Then
A = 90
Call Regpuluhan
End If
If Satuan1 = 1 And Puluhan1 <> 1 Then
A = 10
Call Regsatuan
Elseif Satuan1 = 2 Then
A = 20
Call Regsatuan
Elseif Satuan1 = 3 Then
A = 30
Call Regsatuan
Elseif Satuan1 = 4 Then
A = 40
Call Regsatuan
Elseif Satuan1 = 5 Then
A = 50
Call Regsatuan
Elseif Satuan1 = 6 Then
A = 60
Call Regsatuan
Elseif Satuan1 = 7 Then
A = 70
Call Regsatuan
Elseif Satuan1 = 8 Then
A = 80
Call Regsatuan
Elseif Satuan1 = 9 Then
A = 90
Call Regsatuan
End If
If Puluhan1 = 1 And Satuan1 <> 0 And Satuan1 <> 1 Then
Portd = 120
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
End If
Loop
Ambil_datatimer:
Dirsig = 1
Set Sigout
Waitus 10
Reset Sigout
Dirsig = 0
Set Sigout
Bitwait Sigin , Set
Data_timer = 0
Timer1 = 0
Start Timer1
Do
If Sigin = 0 Then
Data_timer = Timer1
Stop Timer1
Exit Do
End If
If Tifr.2 = 1 Then
Stop Timer1
Tifr.2 = 1
Data_timer = 0
Exit Do
End If
Loop
Stop Timer1
Return
Sub Regratusan:
Portd = A
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 100
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
End Sub
Return
Sub Regpuluhan:
Portd = A
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
Portd = 110
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
End Sub
Return
Sub Regsatuan:
Portd = A
Portb.3 = 0
Waitms X
Portb.3 = 1
Waitms X
Portb.3 = 0
Waitms X
End Sub
Return
h. VIDEO HASILNYA
No comments:
Post a Comment