Не большой пример совместной работы пульта ДУ и кнопок.
Code
$regfile = "ATtiny2313.DAT"
$crystal = 8000000
Enable Interrupts
Config Rc5 = Pind.0
Config Pinb.1 = Output
Relay1 Alias Portb.1
Config Pinb.2 = Output
Relay2 Alias Portb.2
Config Pinb.3 = Output
Relay3 Alias Portb.3
Config Pinb.4 = Output
Relay4 Alias Portb.4
Config Pinb.5 = Output
Relay5 Alias Portb.5
Config Pinb.6 = Output
Relay6 Alias Portb.6
Config Pinb.7 = Output
Relay7 Alias Portb.7
Config Pind.1 = Input
Relay1_on_off Alias Pind.1
Set Portd.1
Config Pind.2 = Input
Relay2_on_off Alias Pind.2
Set Portd.2
Config Pind.3 = Input
Relay3_on_off Alias Pind.3
Set Portd.3
Config Pind.4 = Input
Relay4_on_off Alias Pind.4
Set Portd.4
Config Pind.5 = Input
Relay5_on_off Alias Pind.5
Set Portd.5
Config Pind.6 = Input
Relay6_on_off Alias Pind.6
Set Portd.6
Config Pinb.0 = Input
Relay7_on_off Alias Pinb.0
Set Portb.0
Dim Address As Byte
Dim Command As Byte
Do
Getrc5(address , Command)
If Address = 0 Then
Command = Command And &B01111111
End If
If Relay1_on_off = 0 Or Command = 1 Then
Waitms 500
Toggle Relay1
End If
If Relay2_on_off = 0 Or Command = 2 Then
Waitms 500
Toggle Relay2
End If
If Relay3_on_off = 0 Or Command = 3 Then
Waitms 500
Toggle Relay3
End If
If Relay4_on_off = 0 Or Command = 4 Then
Waitms 500
Toggle Relay4
End If
If Relay5_on_off = 0 Or Command = 5 Then
Waitms 500
Toggle Relay5
End If
If Relay6_on_off = 0 Or Command = 6 Then
Waitms 500
Toggle Relay6
End If
If Relay7_on_off = 0 Or Command = 7 Then
Waitms 500
Toggle Relay7
End If
If Command = 12 Then
Reset Relay1
Reset Relay2
Reset Relay3
Reset Relay4
Reset Relay5
Reset Relay6
Reset Relay7
End If
Loop
End