Potencjometr Alps z silniczkiem sterowanie pilotem RC5
: 11 lis 2017, 14:07
Witam
Mam mały problem z napisaniem kodu do obsługi pilotem potencjometru z silniczkiem o ile sterowanie przyciskami działa to jeśli chce sterować pilotem to już nie chce chodzić dobrze
dodaje kod który napisałem ze by sterować przyciskami i ten kod działa 100%
A tu kod z juz dodana obsluga RC5 ale niestety nie chodzi
Czy może mi ktoś pomoc z tym bardzo proszę
Mam mały problem z napisaniem kodu do obsługi pilotem potencjometru z silniczkiem o ile sterowanie przyciskami działa to jeśli chce sterować pilotem to już nie chce chodzić dobrze
dodaje kod który napisałem ze by sterować przyciskami i ten kod działa 100%
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 16000000
- $hwstack = 28
- $swstack = 28
- $framesize = 28
- '-------------------------------------------------------------------------------------------------------------------------------------------
- Config Pind.0 = Input
- Config Pind.1 = Input
- Config Pinc.7 = Output
- Config Pind.2 = Output
- Config Pind.3 = Output
- Portd.2 = 0
- Portd.3 = 0
- Up Alias Pind.0
- Down Alias Pind.1
- Set Portd.0
- Set Portd.1
- Declare Sub Up1
- Declare Sub Down1
- 'Config Rc5 =
- Do
- If Up = 0 Then Gosub Up1
- 'Portd.2 = 1
- If Down = 0 Then Gosub Down1 'Portd.3 = 1
- Loop
- Sub Up1:
- Portd.2 = 1
- Portc.7 = 0
- Waitms 50
- Portd.2 = 0
- Portc.7 = 0
- End Sub
- Sub Down1:
- Portd.2 = 0
- Portc.7 = 1
- Waitms 50
- Portd.2 = 0
- Portc.7 = 0
- End Sub
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $regfile = "m32def.dat"
- $crystal = 16000000
- $hwstack = 28
- $swstack = 28
- $framesize = 28
- '-------------------------------------------------------------------------------------------------------------------------------------------
- Config Lcdpin = Pin , Db4 = Porta.2 , Db5 = Porta.3 , Db6 = Porta.4 , Db7 = Porta.5 , E = Porta.1 , Rs = Porta.0
- Config Lcd = 16 * 2
- Dim Address As Byte , Command As Byte
- Declare Sub Up1
- Declare Sub Down1
- Config Pinc.7 = Output
- Config Pind.2 = Output
- Config Rc5 = Pinc.2 , Timer = 2
- Plus Alias Portd.2
- Minus Alias Pinc.7
- '-------------------------------------------------------------------------------
- Enable Interrupts
- Do
- Getrc5(address , Command)
- Command = Command And &B01111111
- If Address = 0 And Command = 16 Then Gosub Up1
- 'End If
- If Address = 0 And Command = 17 Then Gosub Down1
- 'End If
- Loop
- Sub Up1:
- Plus = 1 'Portd.2 = 1
- Minus = 0 'Portc.7 = 0
- 'Waitms 100
- 'Plus = 0 'Portd.2 = 0
- 'Minus = 0 'Portc.7 = 0
- End Sub
- Sub Down1:
- Plus = 0 'Portd.2 = 0
- Minus = 1 'Portc.7 = 1
- 'Waitms 100
- 'Portd.2 = 0
- 'Portc.7 = 0
- End Sub