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

Sabertooth Simplified Serial Library

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

Goes in one direction, stops, and then goes in the other direction.

// Simple Example Sample
// Copyright (c) 2012 Dimension Engineering LLC
// See license.txt for license details.
#include <SabertoothSimplified.h>
SabertoothSimplified ST; // We'll name the Sabertooth object ST.
// For how to configure the Sabertooth, see the DIP Switch Wizard for
// http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm
// Be sure to select Simplified Serial Mode for use with this library.
// This sample uses a baud rate of 9600.
//
// Connections to make:
// Arduino TX->1 -> Sabertooth S1
// Arduino GND -> Sabertooth 0V
// Arduino VIN -> Sabertooth 5V (OPTIONAL, if you want the Sabertooth to power the Arduino)
//
// If you want to use a pin other than TX->1, see the SoftwareSerial example.
void setup()
{
SabertoothTXPinSerial.begin(9600); // This is the baud rate you chose with the DIP switches.
}
void loop()
{
ST.motor(1, 127); // Go forward at full power.
delay(2000); // Wait 2 seconds.
ST.motor(1, 0); // Stop.
delay(2000); // Wait 2 seconds.
ST.motor(1, -127); // Reverse at full power.
delay(2000); // Wait 2 seconds.
ST.motor(1, 0); // Stop.
delay(2000);
}