Sabertooth Simplified Serial Library for Arduino: SoftwareSerial/SoftwareSerial.ino

Sabertooth Simplified Serial Library

Sabertooth Simplified Serial Library for Arduino
Control your Sabertooth with Simplified Serial.
SoftwareSerial/SoftwareSerial.ino

Uses a pin other than TX to connect to S1.

// Software Serial Sample
// Copyright (c) 2012 Dimension Engineering LLC
// See license.txt for license details.
#include <SoftwareSerial.h>
#include <SabertoothSimplified.h>
SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1).
SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port.
void setup()
{
SWSerial.begin(9600);
}
void loop()
{
int power;
// Ramp from -127 to 127 (full reverse to full forward), waiting 20 ms (1/50th of a second) per value.
for (power = -127; power <= 127; power ++)
{
ST.motor(1, power);
delay(20);
}
// Now go back the way we came.
for (power = 127; power >= -127; power --)
{
ST.motor(1, power);
delay(20);
}
}