I have an Arduino Mega 2560 and a Trex controller. I would like for the Arduino to listen to a Playstation2 controller and control two DC motors. I’ve got the Arduino listening to the P2S controller. Now I need the Arduino to talk to the Trex controller.
I am ridiculously new to serial connections and I can’t really find an applicable tutorial online. Even the Trex User’s Guide is a little above my head. The user’s guide assumes a higher level of familiarity with serial connections than I have. I’ve checked out the adafruit tutorials, but its not really relevant.
Is there a quickstart guide or tutorial for interfacing an Arduino with the Trex? Or a very simple sketch to see how things should work?
I’m sorry to hear you’re finding the TReX serial interface difficult to understand. As a first step, I suggest you take a look at the sample Arduino program we have for communicating with our newer Simple Motor Controllers:
This program shows you how to use the NewSoftSerial library to send and receive serial bytes from arbitrary digital I/O lines on the Arduino. Once you understand this, it’s just a matter of changing the program to send the right bytes for the TReX (the TReX uses a slightly different protocol from the SMC and the commands are different). The connections you’ll want to make are Arduino pin 4 to TReX SI and Arduino pin 3 to TReX SO. If you have trouble understanding the TReX command documentation, please ask specific questions about what you find confusing.
Also, note that with a little modification, you can connect your Playstation2 controller directly to the TReX and leave the Arduino out of the system entirely. The Playstation2 joysticks are potentiometers that output analog voltages. These voltages are read by the gaming controller converted into digital signals that I presume you are reading with your Arduino. If you open the controller and instead tap into the potentiometer outputs, you can connect them to the analog inputs on the TReX while using the TReX in analog mode. I actually used this technique to test the TReX analog mode during development. Of course, you risk destroying your controller if you mess this up, so make sure you know what you’re doing or are willing to take such a risk!
Thanks Ben, that’s exactly what I am looking for. That will help me very much.
May I suggest adding a link to that from the Trex resources tab? Or posting an Arduino+Trex version of “Hello world”? I never would have found the code in the SMC user guide, and even if I did, I would not presume that it was applicable to the Trex.
I’m glad to hear that’s what you were looking for. Unfortunately, I think if we link it from the TReX resources, people will assume that it is intended for use with the TReX and will get frustrated when it doesn’t. Making a simple Arduino sketch to control the TReX is on my to-do list, and I appreciate your feedback on this.