element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Arduino Nano and Sabertooth driver motor v2.0 Servo Library
  • Blog
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fabiolus
  • Date Created: 24 Jun 2025 5:58 PM Date Created
  • Views 91 views
  • Likes 0 likes
  • Comments 0 comments
  • Sabertooth
  • nano
  • joystick
  • wireless
  • motor
  • arduino
Related
Recommended

Arduino Nano and Sabertooth driver motor v2.0 Servo Library

fabiolus
fabiolus
24 Jun 2025

https://github.com/Fabiolus2020/ArduinoNano_SabertoothDriver_ServoLibrary_1Joystick_2Motors

demo video

https://youtu.be/ejlvw2Omj_Q

Project#5 using

xervo library

1 x Arduino Nano

2 x led

2 resistor 1kOhms

1 x joystick

1 x sabertooth 2x25 version 2.0

2 x dc geared motor

sketch

//created by Fabiolus 2021/01/08

/*


Reference:
- https://www.dimensionengineering.com/info/arduino
- chttps://www.dimensionengineering.com/info/arduino
dipswitch wizzard
- https://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm

Hardware:
- 1x Arduino Uno
- 1x Sabertooth 25 Dual 25A Motor Driver version 2
- 1 x Mini Thumb Joystick
- 2 x dc motors (using servo library since Sabertooth seem to only accept for R/C or micro controller control


Features:
- Move 2 motors using one Joystick Independently

The circuit:
- First motor signal out PWM pin 6 to sabertooth S1
- Second motor signal out PWM pin 5 to sabertooth S2
- Joystick1 X angle attached to analog pins A0
- Joystick1 Y angle attached to analog pins A1


Author:
Fabiolus
sabertooth switch
1= down rc mode input
2= up rc mode input
3= up using Nimh battery
4= up mixed mode differential drive
5= down exponential response
6= down 4x sensivity mode

*/

#include <Servo.h>

const int joyX1 = A0; // Joystick 1 X Axis
const int joyY1 = A1; // Joystick 1 Y Axis
int SW = 2; // button
int SW_state = 0; //button state
int Xval; //value to control speed for POT X
int Yval; //value to control speed for POT Y

Servo ST1, ST2; //two motors

#define GreenLed 7 // green led
#define RedLed 8 // red led
void setup() {

// attach Servo and assign pin with min/max
ST1.attach(6, 1000, 2000);
ST2.attach(5, 1000, 2000);


//setting pin mode
pinMode(SW, INPUT_PULLUP);
pinMode(GreenLed, OUTPUT);
pinMode(RedLed, OUTPUT);


// Inizialize Serial
Serial.begin(9600);
}


void loop() {

//SW_state = digitalRead(SW);
//Serial.println(SW_state);
// analogRead values go from 0 to 1023, analogWrite values from 0 to 255

Xval = analogRead(joyX1);
Xval = map(Xval, 0, 1023, 0, 180); // scale it to use it with the servo (result between 0 and 180)

Yval = analogRead(joyY1);
Yval = map(Yval, 0, 1023, 0, 180); // scale it to use it with the servo (result between 70 and 180)


// sets the servo position according to the scaled value
// ST1.write(servoVal); // sets the servo position according to the scaled value
// ST2.write(servoVal2);
delay(15); // waits for the servo to get there

if (digitalRead(SW) == LOW) {

ST1.attach(6, 1000, 2000);
ST2.attach(5, 1000, 2000);
ST1.write(Xval); // sets the servo position according to the scaled value
ST2.write(Yval);

digitalWrite(RedLed, LOW);
digitalWrite(GreenLed, HIGH);

} else {

ST1.detach(); // sets the servo position according to the scaled value
ST2.detach();
digitalWrite(RedLed, HIGH);
digitalWrite(GreenLed, LOW);
}

}

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube