Kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang bisa menunjukan arah suara berasal menggunakan sensor suara module, jadi terdapat 3 buah sensor suara yang mana sensor tersebut akan mewakili tiap2 posisi, jika salah satu sensor mendapatkan adanya suara maka motor stepper akan bergerak menunjukkan arah sumber suara berasal, untuk aplikasi dari alat ini yaitu bisa digunakan sebagai penunjuk sumber suara, atau bisa juga sebagai kendali device menggunakan suara, dan masih banyak lagi aplikasinya. yang perlu diperhatikan yaitu supply 12 volt untuk stepper berikan resistor 1 Kiloohm agar stepper tidak terlalu panas. untuk lebih jelasnya berikut skema dan programnya.
a. Minimum System
b. Motor Stepper
c. Driver Motor L298
d. Sound Sensor
e. Program Bascom AVR
$regfile = "m16def.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 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Dataadc0 As Word
Dim Dataadc1 As Word
Dim Dataadc2 As Word
'full 360 = 100 step
Cls
Cursor Off
Start Adc
Main:
Dim A As Integer
A = 0
Ddrb.0 = 1
Ddrb.1 = 1
Ddrb.2 = 1
Ddrb.3 = 1
Do
Dataadc0 = Getadc(0)
Dataadc1 = Getadc(1)
Dataadc2 = Getadc(2)
Upperline
Lcd Dataadc0 ; " " ; Dataadc1 ; " " ; Dataadc2
If Dataadc0 >= 520 And Dataadc1 < 520 And Dataadc2 < 520 Then
Goto Sensor1
Cls
Elseif Dataadc0 < 520 And Dataadc1 >= 520 And Dataadc2 < 520 Then
Goto Sensor2
Cls
Elseif Dataadc0 < 520 And Dataadc1 < 520 And Dataadc2 >= 520 Then
Goto Sensor3
Cls
End If
Loop
Sensor1:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 25
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 25
A = 0
Goto Main
Return
Sensor2:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 50
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 50
A = 0
Goto Main
Return
Sensor3:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 75
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 75
A = 0
Goto Main
Return
$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 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Dataadc0 As Word
Dim Dataadc1 As Word
Dim Dataadc2 As Word
'full 360 = 100 step
Cls
Cursor Off
Start Adc
Main:
Dim A As Integer
A = 0
Ddrb.0 = 1
Ddrb.1 = 1
Ddrb.2 = 1
Ddrb.3 = 1
Do
Dataadc0 = Getadc(0)
Dataadc1 = Getadc(1)
Dataadc2 = Getadc(2)
Upperline
Lcd Dataadc0 ; " " ; Dataadc1 ; " " ; Dataadc2
If Dataadc0 >= 520 And Dataadc1 < 520 And Dataadc2 < 520 Then
Goto Sensor1
Cls
Elseif Dataadc0 < 520 And Dataadc1 >= 520 And Dataadc2 < 520 Then
Goto Sensor2
Cls
Elseif Dataadc0 < 520 And Dataadc1 < 520 And Dataadc2 >= 520 Then
Goto Sensor3
Cls
End If
Loop
Sensor1:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 25
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 25
A = 0
Goto Main
Return
Sensor2:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 50
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 50
A = 0
Goto Main
Return
Sensor3:
Do
Portb = &B0000001
Waitms 3
Portb = &B0000010
Waitms 3
Portb = &B0000100
Waitms 3
Portb = &B0001000
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 75
A = 0
Wait 3
Do
Portb = &B00001000
Waitms 3
Portb = &B00000100
Waitms 3
Portb = &B00000010
Waitms 3
Portb = &B00000001
Waitms 3
Incr A
Lowerline
Lcd A
Loop Until A = 75
A = 0
Goto Main
Return
f. VIDEO HASILNYA
No comments:
Post a Comment