
A programik napisalem w BASCOM i na ATmega8
Oto programim odbiornika:
Kod: Zaznacz cały
$regfile = "m8def.dat"
$crystal = 8000000
Declare Sub P1
Config Portc.5 = Output
Config Portc.4 = Output
Config Portc.3 = Output
Config Portc.2 = Output
Config Portc.1 = Output
Led1 Alias Portc.5
Led2 Alias Portc.4
Led3 Alias Portc.3
Led4 Alias Portc.2
Led5 Alias Portc.1
Config Rc5 = Pind.2
Dim Address As Byte , Command As Byte
Enable Interrupts
Do
Getrc5(address , Command)
Command = Command And &B01111111
If Address <> 255 Then
Call P1
End If
Loop
End
Sub P1:
If Command = 1 Then
Toggle Led1
End If
If Command = 2 Then
Toggle Led2
End If
If Command = 3 Then
Toggle Led3
End If
If Command = 4 Then
Toggle Led4
End If
If Command = 5 Then
Toggle Led5
End If
End Sub
Kod: Zaznacz cały
$regfile = "m8def.dat"
$crystal = 8000000
Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input
Config Pinb.1 = Output
Dim Command As Byte , Address As Byte , Togbit As Byte
S1 Alias Pinc.0
S2 Alias Pinc.1
S3 Alias Pinc.2
Set Portc.0
Set Portc.1
Set Portc.2
Do
Debounce S1 , 0 , P1 , Sub
Debounce S2 , 0 , P2 , Sub
Debounce S3 , 0 , P3 , Sub
Loop
End
P1:
Command = 1
Togbit = 0
Address = 1
Do
Rc5send Togbit , Command , Address
Loop Until S1 = 1
Return
P2:
Command = 2
Togbit = 0
Address = 2
Do
Rc5send Togbit , Command , Address
Loop Until S2 = 1
Return
P3:
Command = 3
Togbit = 0
Address =3
Do
Rc5send Togbit , Command , Address
Loop Until S3 = 1
Return
ps program poprawilem jak by ktos chcial to dziala
--------
Proszę w przyszłości ułatwić użytkownikom analizę, stosując się do zaleceń we "Wskazówkach dla piszących". ZbeeGin