ROV 6 motor vectored thrust

Hi, im building an ROV but finding the coding a bit challenging (only have minimal experience with arduinos). 2 joysticks will control the ROV which features 6 motors in vectored format, with 4 motors situated on each corner of the ROV for forward and backward motion, and 2 placed in the middle for upwards and downwards motion.

This is what I've got so far, am I on the right line or have I got it completely wrong? Any help would be much appreciated, don't really know where to go from here.

#include <Servo.h>

// Joystick Settings
static const int JS_CENTER_0 = 511; // Analog reading at center, 0-1023
static const int JS_CENTER_1 = 511;
static const int JS_CENTER_2 = 511;
static const int JS_CENTER_3 = 511;
static const int JS_CENTER_4 = 511;
static const int JS_CENTER_5 = 511;

static const int JS_RANGE_0 = 128; // Analog range, 0-1023
static const int JS_RANGE_1 = 128; // Set to 128 for Parallax joystick
static const int JS_RANGE_2 = 128;
static const int JS_RANGE_3 = 128;
static const int JS_RANGE_4 = 128;
static const int JS_RANGE_5 = 128;

static const int JS_DIR_0 = 1; // +1 or -1
static const int JS_DIR_1 = 1;
static const int JS_DIR_2 = 1;
static const int JS_DIR_3 = 1;
static const int JS_DIR_4 = 1;
static const int JS_DIR_5 = 1;

//Arduino pins
static const byte JS_ADC_0 = A0; //joystick pins
static const byte JS_ADC_0 = A1;
static const byte JS_ADC_0 = A2;
static const byte JS_ADC_0 = A3;
static const byte JS_ADC_0 = A4;
static const byte JS_ADC_0 = A5;

static const byte THRUSTER_FRONT_LEFT = 3; //motor pins
static const byte THRUSTER_FRONT_RIGHT = 5;
static const byte THRUSTER_BACK_LEFT = 6;
static const byte THRUSTER_BACK_RIGHT = 9;
static const byte THRUSTER_VERTICAL_ONE = 10;
static const byte THRUSTER_VERTICAL_TWO = 11;

//Servos
Servo thrusterFrontleft
Servo thrusterFrontRight
Servo thrusterBackLeft
Servo thrusterBackRight
Servo thursterMiddleOne
Servo thrusterMiddleTwo

1 Like

If you are just starting with Arduinos, I would start with a few simple steps before I tackled an ROV.

Start out with the joystick tutorial. Read the value. Print it to the serial monitor.

Out of curiosity, is this to be a submersible watercraft?

thanks mate ill have a look at that.

Yes the ROV is to be fully submersible.

Will this be a tethered submersible? Or will the joysticks be inside it?

You don't need "static" on global variables and I can't believe that none of them are ever going to change which is what "const" means. And since you have lots of variables names that differ just by a number you should probably be looking at using arrays. array - Arduino Reference

Then it's impossible to say if the Servo.h makes any sense without knowing what sort of servos or motors or motor drivers you're using.

Steve