Kód: Egész kijelölése
'-------------------------------------------------------------------
'Vezérlés infra portón. RC5.BAS
'Vezérlő: Relook400 műhold vevő távszabályzója TV állásban. Működik 25 gomb.
'Ezt találtam amivel működöt is.
'Alaplap: Megaboard Chr
'Proci: Mega16
'Rc5 = PIND.3
'Fordító: Bascom AVR 1.11.9.0
'Dátum: 2008 10
'Írta: Kapu48
'Mem foglalás: 26%
'-------------------------------------------------------------------
$regfile = "m16def.dat"
'use byte library for smaller code
'$lib "mcsbyte.lbx"
$crystal = 14745600
$baud = 19200
'This example shows how to decode RC5 remote control signals
'with a SFH506-35 IR receiver.
'Connect to input to PIND.3 for this example
'The GETRC5 function uses TIMER1 and the TIMER1 interrupt.
'The TIMER1 settings are restored however so only the interrupt can not
'be used anymore for other tasks
'tell the compiler which pin we want to use for the receiver input
Config Rc5 = Pind.3
Config Portd.5 = Output 'LED a PortD.5
Portd.5 = 1
Config Porta.6 = Output 'Csípogó
'the interrupt routine is inserted automatic but we need to make it occur
'so enable the interrupts
Enable Interrupts
'reserve space for variables
Dim Address As Byte , Command As Byte , I As Byte , Hz As Word , Hossz As Byte
Print "Waiting for RC5...Power Kilép!"
Do
'now check if a key on the remote is pressed
'Note that at startup all pins are set for INPUT
'so we dont set the direction here
'If the pins is used for other input just unremark the next line
'Config Pind.3 = Input
Getrc5(address , Command)
'we check for the TV address and that is 0
If Address = 0 Then
'clear the toggle bit
'the toggle bit toggles on each new received command
'toggle bit is bit 7. Extended RC5 bit is in bit 6
Command = Command And &B01111111
Print Address ; " " ; Command
Hz = Command * 100
Hossz = Command * 10
Select Case Command
Case 0 : Gosub 0_gomb
Case 1 : Gosub 1_gomb
Case 2 : Gosub 2_gomb
Case 3 : Gosub 3_gomb
Case 4 : Gosub 4_gomb
Case 5 : Gosub 5_gomb
Case 6 : Gosub 6_gomb
Case 7 : Gosub 7_gomb
Case 8 : Gosub 8_gomb
Case 9 : Gosub 9_gomb
Case 10 : Gosub Epg_gomb
Case 12 : Gosub Pover_gomb 'Itt Kilépünk
Case 13 : Gosub Mute_gomb
Case 16 : Gosub Volumep_gomb 'Jobbra
Case 17 : Gosub Volumem_gomb 'Balra
Case 28 : Gosub Ok_gomb
Case 32 : Gosub Fel_gomb
Case 33 : Gosub Le_gomb
Case 50 : Gosub Sarga_gomb
Case 52 : Gosub Kek_gomb
Case 54 : Gosub Zold_gomb
Case 55 : Gosub Piros_gomb
Case 56 : Gosub Felvetel_gomb
Case 57 : Gosub Rcl_gomb
Case 60 : Gosub Text3_gomb
Case 63 : Gosub Text2_gomb
End Select
End If
Loop Until Command = 12
Print " END! "
'...
End
0_gomb: '0
For I = 0 To 1 'Command
Toggle Portd.5
Sound Porta.6 , 10 , 10 'Hossz , Hz
Waitus 200
Next I
Return
1_gomb: '1
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
2_gomb: '2
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
3_gomb: '3
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
4_gomb: '4
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
5_gomb: '5
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
6_gomb: '6
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
7_gomb: '7
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
8_gomb: '8
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
9_gomb: '9
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Epg_gomb: '10
Print " EPG "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Pover_gomb: '12
Print " Kikapcs! "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Mute_gomb: '13
Print " Mute "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Volumep_gomb: '32
Print " Hangero + "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Volumem_gomb: '33
Print " Hangero - "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Ok_gomb: '28
Print " OK "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Fel_gomb: '32
Print " Fel "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Le_gomb: '33
Print " Le "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Sarga_gomb: '50
Print " Sarga "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Kek_gomb: '52
Print " Kek "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Zold_gomb: '54
Print " Zold "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Piros_gomb: '55
Print " Piros "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Felvetel_gomb: '56
Print " Felvétel "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Rcl_gomb: '57
Print " RCL "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Text3_gomb: '60
Print " Text 3. "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
Text2_gomb: '63
Print " Text 2. "
For I = 0 To Command
Toggle Portd.5
Sound Porta.6 , Hossz , Hz
Waitus 200
Next I
Return
' RELOOK400 Recevier TV Address = 0:
'Gomb Command Gomb Command
'1 1 Ki/Be 12
'2 2 Némitás 13
'3 3 Pg + 32
'4 4 Pg - 33
'5 5 Menü 59
'6 6 Hang + 16
'7 7 Hang - 17
'8 8 Nyil < 16
'9 9 Nyil > 17
'0 0 Nyil A 32
'EPG 10 Nyil V 33
'RCL 57
'piros 55 Ok 28
'zöld 54
'sárga 50 TXT alsó sor
'kék 52 2.gomb 63
'recevie 56 3.gomb 60
' RELOOK400 Recevier VCR Addres 5: