Wireless RC Boe-Bot
Waruma
Posts: 21
Hello, I've been trying to get my Boe-Bot to become remote controlled, but I'm having problems with the code. I think I've done everything correctly, but I just can't get it to work. Can someone please help with my code snippets? I don't know if it's timing issues, or what but I can't get it...
Send Code:
'
[ Constants ]
SendOrReceive PIN 5
InfoPin PIN 6
'ReceivePin PIN 6
'
[ Variables ]
pulseLeft VAR Word ' Variable declarations
pulseRight VAR Word
duration VAR Word
Rx VAR Bit
Tx VAR Bit
Setting VAR Bit
Direction VAR Byte
'
[ Initialization ]
'FREQOUT 4, 125, 3000 ' Signal program start/reset.
'
[ Main Routine ]
Tx = 1
Rx = 0
Setting = Tx
'
[ Main Routine ]
IF (Setting = 1) THEN
DEBUG "Program Running!", CR
HIGH SendOrReceive
DO
Direction = "w"
'LOW TransmitPin
PULSOUT InfoPin, 1200
SEROUT InfoPin, 16468, [ "!", Direction ]
PAUSE 10
DEBUG ? Direction
LOOP
ENDIF
Receive Code:
'
[ Constants ]
SendOrReceive PIN 5
InfoPin PIN 6
'ReceivePin PIN 6
'
[ Variables ]
pulseLeft VAR Word ' Variable declarations
pulseRight VAR Word
duration VAR Word
Rx VAR Bit
Tx VAR Bit
Setting VAR Bit
Direction VAR Byte
'
[ Initialization ]
'FREQOUT 4, 125, 3000 ' Signal program start/reset.
'
[ Main Routine ]
Tx = 1
Rx = 0
Setting = Rx
'
[ Main Routine ]
IF (Setting = 0) THEN
LOW SendOrReceive
Direction = 0
DO
SERIN InfoPin, 16468, [WAIT("!"), Direction ]
PAUSE 10
' Direction = "w"
IF (Direction = "w") THEN
pulseRight = 650
pulseLeft = 850
ENDIF
DEBUG ASC ? Direction
'FOR duration = 0 TO 300
PULSOUT 13, pulseLeft
PULSOUT 12, pulseRight
PAUSE 20
'NEXT
LOOP
ENDIF
END
Send Code:
'
[ Constants ]
SendOrReceive PIN 5
InfoPin PIN 6
'ReceivePin PIN 6
'
[ Variables ]
pulseLeft VAR Word ' Variable declarations
pulseRight VAR Word
duration VAR Word
Rx VAR Bit
Tx VAR Bit
Setting VAR Bit
Direction VAR Byte
'
[ Initialization ]
'FREQOUT 4, 125, 3000 ' Signal program start/reset.
'
[ Main Routine ]
Tx = 1
Rx = 0
Setting = Tx
'
[ Main Routine ]
IF (Setting = 1) THEN
DEBUG "Program Running!", CR
HIGH SendOrReceive
DO
Direction = "w"
'LOW TransmitPin
PULSOUT InfoPin, 1200
SEROUT InfoPin, 16468, [ "!", Direction ]
PAUSE 10
DEBUG ? Direction
LOOP
ENDIF
Receive Code:
'
[ Constants ]
SendOrReceive PIN 5
InfoPin PIN 6
'ReceivePin PIN 6
'
[ Variables ]
pulseLeft VAR Word ' Variable declarations
pulseRight VAR Word
duration VAR Word
Rx VAR Bit
Tx VAR Bit
Setting VAR Bit
Direction VAR Byte
'
[ Initialization ]
'FREQOUT 4, 125, 3000 ' Signal program start/reset.
'
[ Main Routine ]
Tx = 1
Rx = 0
Setting = Rx
'
[ Main Routine ]
IF (Setting = 0) THEN
LOW SendOrReceive
Direction = 0
DO
SERIN InfoPin, 16468, [WAIT("!"), Direction ]
PAUSE 10
' Direction = "w"
IF (Direction = "w") THEN
pulseRight = 650
pulseLeft = 850
ENDIF
DEBUG ASC ? Direction
'FOR duration = 0 TO 300
PULSOUT 13, pulseLeft
PULSOUT 12, pulseRight
PAUSE 20
'NEXT
LOOP
ENDIF
END
Comments
Thanks for your help!