Ben,
Below is the code I am using with the Arduino. It compiles and uploads fine. I had to track down the NewSerial library but not a big deal. I have attached the pin on the TReX that is designated as Logic-level TReX Jr serial in to the PIN 4 on the Arduino. I have attached the GND pin on the TReX to the GND pin on the Arduino. I have not connected the pin on the TReX as Logic-level TReX Jr Serial Out to anything. I have the mode jumper removed entirely which, I think, sets the mode ot serial. I have the mixed jumper in place. I have the BEC jump remoed. I have nothing connected to the Channel pins. Nothing happens? What am I doing wrong?
Here’s the code, it is a direct copy from the link you provied.
#include <SoftwareSerial.h>
#include <NewSoftSerial.h>
#define rxPin 3 // pin 3 connects to SMC TX (not used in this example)
#define txPin 4 // pin 4 connects to SMC RX
NewSoftSerial mySerial = NewSoftSerial(rxPin, txPin);
// required to allow motors to move
// must be called when controller restarts and after any error
void exitSafeStart()
{
mySerial.print(0x83, BYTE);
}
// speed should be a number from -3200 to 3200
void setMotorSpeed(int speed)
{
if (speed < 0)
{
mySerial.print(0x86, BYTE); // motor reverse command
speed = -speed; // make speed positive
}
else
{
mySerial.print(0x85, BYTE); // motor forward command
}
mySerial.print((unsigned char)(speed & 0x1F), BYTE);
mySerial.print((unsigned char)(speed >> 5), BYTE);
}
void setup()
{
// initialize software serial object with baud rate of 38.4 kbps
mySerial.begin(38400);
// the Simple Motor Controller must be running for at least 1 ms
// before we try to send serial data, so we delay here for 5 ms
delay(5);
// if the Simple Motor Controller has automatic baud detection
// enabled, we first need to send it the byte 0xAA (170 in decimal)
// so that it can learn the baud rate
mySerial.print(0xAA, BYTE); // send baud-indicator byte
// next we need to send the Exit Safe Start command, which
// clears the safe-start violation and lets the motor run
exitSafeStart(); // clear the safe-start violation and let the motor run
}
void loop()
{
setMotorSpeed(3200); // full-speed forward
delay(1000);
setMotorSpeed(-3200); // full-speed reverse
delay(1000);
}