How to program 2 motors in a rc tank to be used by 2 joysticks

How to program 2 motors in a rc tank to be used by 2 joysticks? I need help with code! I have a arduino motor shield and want to control a rc tank what code should i use? give me tips!

penokio2:
I need help with code!

We will be happy to help but you need to post the code you need help with and explain what part is causing you a problem.

…R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom.... :slight_smile:

I have 0 experience and i have a joystick with 3 pins and a normal electric motor. i got an arduino motor shield. its a tank with 2 tracks and 2 motors and i want to use 2 joysticks to control it. These are the motors. https://www.kjell.com/se/sortiment/el-verktyg/elektronik/elektromekanik/motorer/dc-motor-6-14-v-p36209 i know how to connect everything just need a code that can controll the motors.

I want the motors to be stepless i am extremly bad at code so post examples and ill try them. This code works but no joystick involved it just gets the motors spinning. Also the joystick has 4 pins
``void setup() {

//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin

}

void loop(){

//Motor 1 forward @ full speed
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed

//Motor 2 backward @ half speed
digitalWrite(13, LOW); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 123); //Spins the motor on Channel B at half speed

delay(3000);

digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(9, HIGH); //Engage the Brake for Channel B

delay(1000);

//Motor 1 Backward @ full speed
digitalWrite(12, LOW); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 123); //Spins the motor on Channel A at half speed

//Motor 2 forward @ full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at full speed

delay(3000);

digitalWrite(9, HIGH); //Engage the Brake for Channel A
digitalWrite(9, HIGH); //Engage the Brake for Channel B

delay(1000);``

penokio2:
Also the joystick has 4 pins

Can you post a link to data/specs/seller of the joystick please?
A picture of the joystick will help.
Thanks.. Tom.. :slight_smile: