Help with Basic Stamp and Trex Jr

I am trying to get the basic stamp 2 to work with the trex controller. I am having trouble understanding serout commands. I have read the trex jr user manual and gone over the serial communication commands. Here is how I have it setup so far:

-Motor 1 and Motor 2 going to their respective motors
-I removed the serial/RC/analog jumper and when I power up my trex board I get a solid red led. from the docs I assume this is correct for serial only.
-3 pin female connection from the trex to my basic2 stamp. On the Trex the black wire is right in the middle on pin 3. I have this plugged into my basic stamp 3 pin male connector #15.

what I want to due is just power up the motors (motor #1 and #2) to make sure everything works and give me a basis to start from.

Currently I have:
SEROUT 15, 16416,[128,7,240,127]

which just makes the green led flash for a split second.
so I tried:
FOR speed = 0 TO 127

SEROUT 15, 16416,[128,7,240,127]

which makes it pulse longer, but not luck spinning the motors.

any help on just getting it all to work would be great.




The sequence [128,7,240,127] is not a valid TreX Jr command. Most importantly, only the first byte of any command should have the most significant bit set - that means the first byte should be greater than or equal to 128 and the rest should be less than 128.

Now, it looks like you are trying to use the expanded protocol, which is not useful unless you have multiple Pololu devices on the same serial line. Instead of that, you should start with the compact protocol: just use [240, 127], without the extra bytes at the beginning.

The command you tried to use was 240, or 0xF0, which is the “set auxiliary motor” command. Do you have anything plugged in to the auxiliary motor port? You probably want one of the commands 0xD0-0xDF instead.

See the command documentation for more information, and let us know if you still can’t get it working!


hey Paul,

Thanks for the quick reply. I noticed people always get help on these forums and that is why I chose Pololu over some other controllers.

Would you be willing to give me the commands I need to run motor1 at speed 127 and also a separate command to run motor 2 at 127?



I made a little progress.

This command now works:

SEROUT 10, 16416,[128,7,66,128] for motor 1

However this command:

SEROUT 10, 16416,[128,7,74,128] should work for motor 2 but it doesnt, i cant get motor 2 to work.

Also, if i just specify the short syntax SEROUT 10, 16416,[74,128] it still doesnt work.

Whats more I dont understand the set motor 1 and 2 command at all. can you elaborate on that.

Again, Thanks a bunch, I am making some progress.


I’m sorry if the docs don’t make this totally clear, but again, it’s really important that the first byte is greater than or equal to 128, and all the remaining bytes of the command are less than 128, since that’s how the TreX Jr identifies a command packet. None of your examples have those properties, so I don’t think that they could possibly work. So I’m not sure how you got motor 1 moving at all - did you send anything else that could have done it?

According to the manual, command 0xC2 is used to set motor 1 forward, and command 0xCA is used to set motor 2 forward. In decimal, these commands are 194 and 202; 128 more than what you tried in the compact protocol mode. You should use the value-128 only for the expanded protocol, which you shouldn’t be using.

The data byte can be 0-127, where 127 is the maximum speed. So you should be able to run both motors by sending [194, 127] then [202, 127].

Does that make sense? I’ll be happy to answer more questions if you have them! By the way, what are you using the TreX Jr to control?


The compact protocol just wont work at all. I think I am becoming more proficient at understanding how this all works, but even with the examples you gave me I cant get it working.

I did however hookup the trex jr to the windows configuration util and was able to control the motors that way so I know the board is working.

I am sending these serial commands from my Basic Stamp board. The entire command I am sending from Pbasic is: SEROUT 10, 16416, [194, 127]

I have the RC/Serial/Analog jumper completely removed, the BEC jumper removed, and just the serial connection per the diagram going to my basic stamp.

It seems to me maybe I am missing something. Does channel 1 RC have to be hooked up for the serial commands to work? Is there anything else I should review to get this working?

Thanks for all the help.



I had my baudrates all jacked up in Pbasic. It works as you explained now.

Thanks for all the help


Great! I’m glad you got it working. Let us know if you need more help,