Pada kesempatan yang istimewa kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang mana alat ini untuk edukasi ke pelajar tentang sistem-sistem yang ada di mobil atau mini bus. jadi dengan menggunakan penunjuk remote tv, jika tombol ditekan maka akan menghidupkan bagian yang telah diisyaratkan sebelumnya, misalnya lampu sore atau lampu kota, kemudian klakson dan suara mesin. Alat ini menggunakan mikrokontroller ATMega16 dan receiver TSOP yang biasa digunakan untuk receiver TV. untuk lebih jelasnya berikut adalah skema dan programnya.
a. Minimum System ATMega
b. IR TSOP
c. Remote TV for Sony
d. 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
'Cursor Off
'Cls
Config Timer0 = Timer , Prescale = 256
Stop Timer0
Config Pind.3 = Input
Set Portd.3
Pin_ir Alias Pind.3
Config Int1 = Falling
On Int1 Isr_int1
Ddrb = &B11111111
Ddra = &B11111111
Ddrd.0 = 1
Ddrd.1 = 1
Ddrd.2 = 1
Ddrd.6 = 1
Ddrd.7 = 1
Porta.7 = 1
Dim M As Integer
Dim Data_ir As Word
Dim Cnt_ir As Byte
Dim Flag_ir_start As Bit
Dim Flag_ir_ok As Bit
Dim Suhu_ref As Word
Dim Suhu As Word
'Cls
'Cursor Off
'Locate 1 , 3
'Lcd "SONY DECODERx"
Wait 1
Enable Interrupts
Enable Int1
Data_ir = 0
Porta.3 = 1
M = 0
Ddrc.6 = 1
Portc.6 = 1
Ddrc.4 = 1
Portc.4 = 1
Ddrc.5 = 1
Portc.5 = 1
Portd.6 = 1
Portd.7 = 1
Portb.0 = 1
Portb.1 = 1
Portb.4 = 1
Portb.6 = 1
Porta.4 = 1
Ddrc.7 = 1
Portc.7 = 1
Ddra.0 = 1
Porta.0 = 1
Ddra.1 = 1
Porta.1 = 1
Do
If Flag_ir_ok = 1 Then
Reset Flag_ir_ok
Disable Int1
Gosub Isr_int1
Cls
Cursor Off
Locate 1 , 3
Lcd "Data= " ; Data_ir
If Data_ir = 137 And M = 0 Then
Portb.0 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 137 And M = 1 Then
Portb.0 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 128 And M = 0 Then
Portb.1 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 128 And M = 1 Then
Portb.1 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 129 And M = 0 Then
Portb.4 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 129 And M = 1 Then
Portb.4 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 130 And M = 0 Then
Portb.6 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 130 And M = 1 Then
Portb.6 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 134 And M = 0 Then
Porta.4 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 134 And M = 1 Then
Porta.4 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 135 And M = 0 Then
Porta.3 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 135 And M = 1 Then
Porta.3 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 148 And M = 0 Then
Porta.7 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 148 And M = 1 Then
Porta.7 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 146 And M = 0 Then
Portd.7 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 146 And M = 1 Then
Portd.7 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 147 And M = 0 Then
Portd.6 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 147 And M = 1 Then
Portd.6 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 149 And M = 0 Then
Portc.7 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 149 And M = 1 Then
Portc.7 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 136 And M = 0 Then
Portc.6 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 136 And M = 1 Then
Portc.6 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 131 And M = 0 Then
Porta.0 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 131 And M = 1 Then
Porta.0 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 132 And M = 0 Then
Porta.1 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 132 And M = 1 Then
Porta.1 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 133 And M = 0 Then
Porta.0 = 0
Porta.1 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 133 And M = 1 Then
Porta.0 = 1
Porta.1 = 1
M = 0
Data_ir = 0
End If
If Data_ir = 229 And M = 0 Then
Portb.0 = 0
Portb.1 = 0
Portb.4 = 0
Portb.6 = 0
Porta.0 = 0
Porta.1 = 0
Porta.4 = 0
Porta.3 = 0
Portc.6 = 0
Portc.7 = 0
M = 1
Data_ir = 0
End If
If Data_ir = 229 And M = 1 Then
Portb.0 = 1
Portb.1 = 1
Portb.4 = 1
Portb.6 = 1
Porta.0 = 1
Porta.1 = 1
Porta.4 = 1
Porta.3 = 1
Portc.6 = 1
Portc.7 = 1
M = 0
Data_ir = 0
End If
Data_ir = 0
Reset Flag_ir_ok
Enable Int1
End If
Wait 1
Loop
Isr_int1:
Timer0 = 0
Start Timer0
Bitwait Pin_ir , Set
Stop Timer0
If Cnt_ir = 0 Then
If Timer0 > 110 And Timer0 < 120 Then
Set Flag_ir_start
Incr Cnt_ir
End If
End If
If Flag_ir_start = 1 And Cnt_ir > 0 Then
Decr Cnt_ir
If Timer0 < 32 Then
Data_ir.cnt_ir = 0
Else
Data_ir.cnt_ir = 1
End If
Cnt_ir = Cnt_ir + 2
If Cnt_ir > 11 Then
Shift Data_ir , Right , 1
Reset Flag_ir_start
Set Flag_ir_ok
Cnt_ir = 0
End If
End If
Return
e. VIDEO HASILNYA
No comments:
Post a Comment