Logo

Forums » Segbot » Sabertooth 2x25 one motor always runs

normgr00
Avatar

Building a Segbot and I have a problem with my Sabertooth 2x25 in that M1 motor always runs clockwise but not at full speed. Could it be defective? Below is test code I made to test it running in Simple Serial mode. M1 motor always runs clockwise no matter what I send to it. As a test I configured it for analog mode using a pot to controll and both motors respond correctly. I have also tried to cast the command word into char, int and the default byte but no difference. I have also written both 0 (all motors stop) and 64 (M1 motor stop) but M1 still runs. At $125 buying another Sabertooth is an expensive test. Here is the test program I used. Should this test work?:

#include <SoftwareSerial.h>
SoftwareSerial motorSerial(2, 3); // RX, TX
byte m1_speed=0;

void setup(){
    motorSerial.begin(9600);
}

void loop (){
  motorSerial.print(m1_speed);
  delay (500);
  }
  

normgr00
Avatar

Solved my problem.

I needed to use 

motorSerial.write(m1_speed);

not 

motorSerial.print(m1_speed);

johndavid400
Avatar

Hi normgr00,

Yes, this was something they updated when they released Arduino IDE 1.0, so if you are using 1.0 or newer, you have to use Serial.write to get the byte value instead of trying to force Serial.print into a byte.

My book was published pre 1.0, so there is no mention of this in there, but the newer Segbot code has this in place.

Thanks,
JD