i could really use some help with my arduino project it is 2 motors controlled in tandem by a joystick, or it would be if i could get it to work. i have a code for the motors to run separately it is this: #include <Servo.h>

Serial.print(analogRead(joyH)); Serial.print ("---"); Serial.print(analogRead(joyV)); Serial.println ("----------------");}but what i need it to do is run both of the DC motors in tandem and the bot needs to be able to make zero point turns. any help at all would be extremely helpful, thank you for your time

yes i want them to go opposite directions when making the turns and, no it does not have a trigger or switch. is it possible to make them both go the same way when the joystick is in the forward or backwards positions and go opposite directions when in the left or right positions? if so please help, any advice for coding this would be appreciated.

The problem you may have with your setup is that a joystick is capable of having both your forward/reverse and turn commands at the same time (like joystick pushed forward and to the left at the same time). You might put the stick shaft in a + cutout such that the joystick can't be put in a diagonal position. A code fix might be possible by making exclusive loops for forward/reverse and turning.

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

this might seem like an odd question but regardless, is it possible to use the style of code that i have been using to run the motors parallel at all times? if so does anyone have any advice how? Ive become stuck.

this might seem like an odd question but regardless, is it possible to use the style of code that i have been using to run the motors parallel at all times? if so does anyone have any advice how? Ive become stuck.

If you mean have the opposite side continuous rotation servos move forward and reverse together, then the below is a usual way where the pot value is mapped to 0-180 deg.

it worked...kinda, the code made the 1 run continually in reverse, what i need is for when the joystick value is above the center value heading forward on the joystick to have both motors run forward (same idea in reverse), and when the joystick is headed left the two values are one half of the value forward for one motor and the other motors value is half the value going backwards. sorry if i seem clueless as i kinda am towards complex programming. once again any help would be appreciated.

The change you propose was what I considered when I first read your topic. They should be easy to implement.

The only issue with your proposal is that you won't be able to spin on a dime.

If, instead, you use the left and right amount as a differential to be applied to both motors (one positive, one negative), then when the stick is centered fore and aft (at the midpoint of the throw), then you can still have a positive and negative wheel speed, and can spin in place. The speed at which you spin is related to how far left or right you move the stick. Which way you move the stick controls the direction of spin.

servoVal3 = map(servoVal3, 0, 1023,1000, 1750); // scale it to use it with the servo (result between 0 and 180) servoVal4 = map(servoVal4, 0, 1023, 1250, 1750); // scale it to use it with the servo (result between 70 and 180)

servoVal1 = map(servoVal1, 0, 1023,1000, 1750); // scale it to use it with the servo (result between 0 and 180) servoVal2 = map(servoVal2, 0, 1023, 1250, 1750); // scale it to use it with the servo (result between 70 and 180)

myservo2.write(servoVal1); // sets the servo position according to the scaled value myservo1.write(servoVal2);

this is the new code i came up with to run the robot to make zero point turns, the issue is now that i cant figure out how to make the bot run in parallel when moving forwards and backwards, any ideas?

Below is some pot test code. You might make something similar using "while" loops to trap the input of one of the pots while it is not centered, excluding any control input from the other pot. That should prevent control conflicts between forward/reverse and clockwise/counterclockwise servo operation.

I did something simular with DC motors. It uses 2 variable "z" -forward movement and "y" - left and right movement.Note this is only a snip of the full code, the rest is just receiving the data and sending it to here. You may also be able to alter it to use servos instead of DC motors.

servoVal3 = map(servoVal3, 0, 1023,1000, 1750); // scale it to use it with the servo (result between 0 and 180) servoVal4 = map(servoVal4, 0, 1023, 1250, 1750); // scale it to use it with the servo (result between 70 and 180)

servoVal1 = map(servoVal1, 0, 1023,1000, 1750); // scale it to use it with the servo (result between 0 and 180) servoVal2 = map(servoVal2, 0, 1023, 1250, 1750); // scale it to use it with the servo (result between 70 and 180)

myservo2.write(servoVal1); // sets the servo position according to the scaled value myservo1.write(servoVal2);

delay(15); // waits for the servo to get there

}

/*** Display joystick values*/void outputJoystick(){

Serial.print(analogRead(joyH)); Serial.print ("---"); Serial.print(analogRead(joyV)); Serial.println ("----------------");}i managed to get the 2 motors to make zero point turns, however i now cant get any headway into running at the same time to go forwards and backwards. any ideas/ help would be massively appreciated.