Robot car using Arduino Uno & Sabertooth 2 X 12. This video uses the Arduino Uno coupled with a Sabertooth 2X12 to run 2 wheelchair motors in differential drive mode. The Arduino is sending serial data to control both motors, using the free sample code available from dimension engineering. If you enjoyed this video please visit some sponsors:
Model Train Layout Ideas:
https://7c9d3ghgg5qlk4b6fc-726ti6b.hop.clickbank.net/
Automobile Electronics:
https://1b9e1ttlofbegc82-fr9hb8pag.hop.clickbank.net/
Green Energy:
https://cd840siik6jmp-cd10n6j-atfr.hop.clickbank.net/
, https://i.ytimg.com/vi/mccEfqs2aUE/hqdefault.jpg
source
2021-03-23
Hello, is this project still topical or not ?
Because we are a small group of student and we build a robot using 2 wheelchair motors controled by an Arduino Mega, and we use the Sabertooth 2×12 shield but it doesn't work.
So maybe the pb comes from the code, is it possible to have the code and maybe some tips please ?
You can contact me with my email adress: paul.sion@esme.fr
Thank you very much !!
Can you please email me the Code/ sketch for it? Ankurgateway@yahoo.ca
Thanks in advance
What are your dip switches set to?
dead project? did ya get any sensors working? would love to see an update thanks!!
superrrr adiopoli…powliche muthe
!!!
Perhaps you should have the batteries in series and with a sabertooth, why do you need an arduino?
Hi Fcord23
can you share to me source code diagrams with arduino uno.
my email: langtupt@gmail.com
Plaese help
Thank you very much
Hi fcord23,
I am trying to connect my arduino uno to sabertooth and to a 12v battery which will run to wheelchair motors. Do you have a simple sketch showing where all the wires go?? My email is nico8697@mac.com I'd really really appreciate the help !!!!!
greetings- great project and superbly done. If you don't mind me asking a have a similar project I need some help with.
I am trying to control 2 DC 24volt motors using an adruino uno, a sabertooth 2×25 motor controller, and a bluetooth shield (HC06).
I already have the RC of the two motors set up but would like to use an RC control app on my android phone to control the device via Bluetooth instead. I am a beginner at the adruino and c and none of the examples, code etc have worked. Below is my setup and code (code is from tinkernut.com). My problem is the code and how to transmit left and right signals and back and forth signals through S1 and S2 and PWM pins 3 and 5.
I can continue to use the RC transmitter and receiver but would ultimately like the flexibility of android RC styled control app.
Set up-
Uno Tx to HC06-Rx (breadboard)
Uno Rx to HC06-Tx (breadboard)
Uno pwm pin 3 to Sabertooth S1
Uno pwm pin 5 to Sabertooth S2
Sabertooth 0v to Uno Ground
Sabertooth 5v -N/A
Motor 1 (right) to Sabertooth right side + and –
Motor 2 (left) to Sabertooth left side + and –
24v battery to Sabertooth center + and –
Uno and bluetooth powered by 9volt battery to Uno power supply
Bluetooth connected to breadboard receiving power via +/- jumper wires from Uno 0v and 5v
#include "EEPROM.h"
#define D1 2 // direction of motor rotation 1 ? should this be S1 and pin 3
#define M1 3 // PWM left motor ? do I delete this or also change it S1 pin 3
#define D2 4 // direction of motor rotation 2 ? should this be S2 and pin 5
#define M2 5 // PWM right motor ? do I delete this or also change it to S2 and pin 5
#define HORN 13 // additional channel 1 (do not need this function)
//#define autoOFF 2500 // milliseconds after which the robot stops when the connection
#define cmdL 'L' // UART-command for left motor
#define cmdR 'R' // UART-command for right motor
#define cmdH 'H' // UART-command for additional channel (for example Horn)
#define cmdF 'F' // UART-command for EEPROM operation
#define cmdr 'r' // UART-command for EEPROM operation (read)
#define cmdw 'w' // UART-command for EEPROM operation (write)
char incomingByte; // incoming data
char L_Data[4]; // array data for left motor
byte L_index = 0; // index of array L
char R_Data[4]; // array data for right motor
byte R_index = 0; // index of array R
char H_Data[1]; // array data for additional channel
byte H_index = 0; // index of array H
char F_Data[8]; // array data for EEPROM
byte F_index = 0; // index of array F
char command; // command
unsigned long currentTime, lastTimeCommand, autoOFF;
void setup() {
Serial.begin(9600); // initialization UART
pinMode(HORN, OUTPUT); // additional channel
pinMode(D1, OUTPUT); // output for motor rotation
pinMode(D2, OUTPUT); // output for motor rotation
/*EEPROM.write(0,255);
EEPROM.write(1,255);
EEPROM.write(2,255);
EEPROM.write(3,255);*/
timer_init(); // initialization software timer
}
void timer_init() {
uint8_t sw_autoOFF = EEPROM.read(0); // read EEPROM "is activated or not stopping the car when losing connection"
if(sw_autoOFF == '1'){ // if activated
char var_Data[3];
var_Data[0] = EEPROM.read(1);
var_Data[1] = EEPROM.read(2);
var_Data[2] = EEPROM.read(3);
autoOFF = atoi(var_Data)*100; // variable autoOFF ms
}
else if(sw_autoOFF == '0'){
autoOFF = 999999;
}
else if(sw_autoOFF == 255){
autoOFF = 2500; // if the EEPROM is blank, dafault value is 2.5 sec
}
currentTime = millis(); // read the time elapsed since application start
}
void loop() {
if (Serial.available() > 0) { // if received UART data
incomingByte = Serial.read(); // raed byte
if(incomingByte == cmdL) { // if received data for left motor L
command = cmdL; // current command
memset(L_Data,0,sizeof(L_Data)); // clear array
L_index = 0; // resetting array index
}
else if(incomingByte == cmdR) { // if received data for left motor R
command = cmdR;
memset(R_Data,0,sizeof(R_Data));
R_index = 0;
}
else if(incomingByte == cmdH) { // if received data for additional channel
command = cmdH;
memset(H_Data,0,sizeof(H_Data));
H_index = 0;
}
else if(incomingByte == cmdF) { // if received data for EEPROM op
command = cmdF;
memset(F_Data,0,sizeof(F_Data));
F_index = 0;
}
else if(incomingByte == 'r') command = 'e'; // end of line
else if(incomingByte == 't') command = 't'; // end of line for EEPROM op
if(command == cmdL && incomingByte != cmdL){
L_Data[L_index] = incomingByte; // store each byte in the array
L_index++; // increment array index
}
else if(command == cmdR && incomingByte != cmdR){
R_Data[R_index] = incomingByte;
R_index++;
}
else if(command == cmdH && incomingByte != cmdH){
H_Data[H_index] = incomingByte;
H_index++;
}
else if(command == cmdF && incomingByte != cmdF){
F_Data[F_index] = incomingByte;
F_index++;
}
else if(command == 'e'){ // if we take the line end
Control4WD(atoi(L_Data),atoi(R_Data),atoi(H_Data));
delay(10);
}
else if(command == 't'){ // if we take the EEPROM line end
Flash_Op(F_Data[0],F_Data[1],F_Data[2],F_Data[3],F_Data[4]);
}
lastTimeCommand = millis(); // read the time elapsed since application start
}
if(millis() >= (lastTimeCommand + autoOFF)){ // compare the current timer with variable lastTimeCommand + autoOFF
Control4WD(0,0,0); // stop the car
}
}
void Control4WD(int mLeft, int mRight, uint8_t Horn){
bool directionL, directionR; // direction of motor rotation L298N
byte valueL, valueR; // PWM M1, M2 (0-255)
if(mLeft > 0){
valueL = mLeft;
directionL = 0;
}
else if(mLeft < 0){
valueL = 255 – abs(mLeft);
directionL = 1;
}
else {
directionL = 0;
valueL = 0;
}
if(mRight > 0){
valueR = mRight;
directionR = 0;
}
else if(mRight < 0){
valueR = 255 – abs(mRight);
directionR = 1;
}
else {
directionR = 0;
valueR = 0;
}
analogWrite(M1, valueL); // set speed for left motor
analogWrite(M2, valueR); // set speed for right motor
digitalWrite(D1, directionL); // set direction of left motor rotation
digitalWrite(D2, directionR); // set direction of right motor rotation
digitalWrite(HORN, Horn); // additional channel
}
void Flash_Op(char FCMD, uint8_t z1, uint8_t z2, uint8_t z3, uint8_t z4){
if(FCMD == cmdr){ // if EEPROM data read command
Serial.print("FData:"); // send EEPROM data
Serial.write(EEPROM.read(0)); // read value from the memory with 0 address and print it to UART
Serial.write(EEPROM.read(1));
Serial.write(EEPROM.read(2));
Serial.write(EEPROM.read(3));
Serial.print("rn"); // mark the end of the transmission of data EEPROM
}
else if(FCMD == cmdw){ // if EEPROM data write command
EEPROM.write(0,z1); // z1 record to a memory with 0 address
EEPROM.write(1,z2);
EEPROM.write(2,z3);
EEPROM.write(3,z4);
timer_init(); // reinitialize the timer
Serial.print("FWOKrn"); // send a message that the data is successfully written to EEPROM
}
}
Hi,
I am looking to use the sabertooth for a differential drive snow plow. Have you done any tests with your robot in a high load situation, like pushing against a wall (almost stall condition).
I was wondering how the 2x12amp controller handles that. Does it heat up, stutter etc…
thats cool!! i like it check my arduino robot http://m.youtube.com/playlist?list=PLU41q1BoUsYaC25gndZE0WIZLjEPRNzHB still work in progress but is my fist robot
Hello, I must say its very good stuff. What kind of batteries are you using? Are these deep cycle? I am planning on doing the same thing but a snow plow robot where it will be controlled through a smart phone.