# Basic Stamp 2 Remote Control Bot

#### Wheelie016

Nov 20, 2012
10
I am using the Basic Stamp 2, Two Xbee's, and a Pololu Serial Servo Controller. My goal is is to have the bot controlled from my computer. The thing is, it works some of the time, just more often that it doesn't than it does..alot more often. This is my code:

'Remote Control Bot v1

Direction VAR Word

Xbee CON 12
ServoCtrl CON 0
R_ServoP CON 1
L_ServoP CON 5
LCD_P CON 14

Setup:
SEROUT 14, 84, [22,12]
PAUSE 5

Main:

SERIN 12, 84, [direction]
SEROUT 14, 84, [direction]

IF direction = "w" THEN
SEROUT 1, 84, [$80,$01,$04,R_ServoP,20,50] SEROUT 1, 84, [$80,$01,$04,L_ServoP,24,50]
SEROUT 14, 84, [12,"Moving Forward"]
GOTO Main

ELSEIF direction = "a" THEN
SEROUT 1, 84, [$80,$01,$04,R_ServoP,21,50] SEROUT 1, 84, [$80,$01,$04,L_ServoP,22,50]
SEROUT 14, 84, [12,"Turning Left"]
GOTO Main

ELSEIF direction = "s" THEN
SEROUT 1, 84, [$80,$01,$04,R_ServoP,24,50] SEROUT 1, 84, [$80,$01,$04,L_ServoP,20,50]
SEROUT 14, 84,[12,"Moving Backwards"]
GOTO Main
ELSEIF direction = "d" THEN
SEROUT 1, 84, [$80,$01,$04,R_ServoP,22,50] SEROUT 1, 84, [$80,$01,$04,L_ServoP,23,50]
SEROUT 14, 84,[12,"Turning Right"]
GOTO Main

ELSE
SEROUT 14, 84, [12,"[Invalid Character]"]
PAUSE 5
ENDIF

GOTO Main

I've tried replacing the SERIN command with DEBUGIN to make sure it wasn't something to do with the Xbee. The LCD connected to Pin 14 responds, as in it shows "Moving Forward" when "w" is sent to the Stamp, but the Servo Controller does not. I can't for the life of me figure out why?? On the rare occasions that it does work, there is a green LED on the Controller that shows incoming serial data, but 9 times out of 10, the Yellow Standby LED just stays on as if the Stamp isn't sending it anything.

Any advice on how to figure out what might be the cause of it's unreliable performance, whether it be software or hardware related, would be much appreciated.

Replies
1
Views
882
Replies
2
Views
3K
G
Replies
6
Views
1K
Raveninghorde
R
Replies
5
Views
2K
S
Replies
2
Views
1K
Jamie
J