Found this link on the web, great explanation on tank steering controll with one stick....
http://home.kendra.com/mauser/Joystick.html
Like I said im not a computer person but I think this could be made to work.
Im coping and pasting some code from the arduino forum.....
int joyPin1 = 4; // slider variable connecetd to analog pin 0
int joyPin2 = 5; // slider variable connecetd to analog pin 1
int coordX = 0; // variable to read the value from the analog pin 0
int coordY = 0; // variable to read the value from the analog pin 1
int centerX = 527; // we measured the value for the center of the joystick
int centerY = 512;
int actualZone = 0;
int previousZone = 0;
void setup()
{
Serial.begin(9600);
}
void loop() {
// reads the value of the variable joystick
coordX = analogRead(joyPin1);
coordY = analogRead(joyPin2);
//maps from 0-1023 POT range to -100 - 100 range of formula
int coordXmapped = map(coordX,0,1023,-100,100);
int coordYmapped = map(coordY,0,1023,-100,100);
// we print int the terminal
Serial.print("X Axis: ");
Serial.print(coordX); //joystick X
Serial.print("\n");
Serial.print("Y axis: ");
Serial.print(coordY); //joystick Y
Serial.print("\n");
Serial.print("X Axis Mapped: ");
Serial.print(coordXmapped); //joystick X mapped value
Serial.print("\n");
Serial.print("Y Axis Mapped: ");
Serial.print(coordYmapped); //joystick Y mapped value
Serial.print("\n");
// invert the X coordinate to be used in the formula
int coordXinvert = (coordXmapped*-1);
// the formulas
int v = ((100-abs(coordXinvert)) * (coordYmapped/100)+coordYmapped);
int w = ((100-abs(coordYmapped)) * (coordXinvert/100) + coordXinvert);
int rightwheel = ((v+w)/2);
int leftwheel = ((v-w)/2);
Serial.print("rightwheel: ");
Serial.print(rightwheel);
Serial.print("\n");
Serial.print("leftwheel: ");
Serial.print(leftwheel);
Serial.print("\n");
//Now we have to use some trickery to setup the motor controller outputs
int rightfrontback = 1;
if(rightwheel<0)
{
rightfrontback = 0;
}
int leftfrontback = 1;
if(leftwheel<0)
{
leftfrontback = 0;
}
int rightmotor = map(abs(rightwheel),0,100,0,255);
int leftmotor = map(abs(leftwheel),0,100,0,255);
Serial.print("rightwheel motor: ");
Serial.print(rightmotor);
Serial.print("\n");
Serial.print("rightwheel motor direction: ");
Serial.print(rightfrontback);
Serial.print("\n");
Serial.print("leftwheel motor: ");
Serial.print(leftmotor);
Serial.print("\n");
Serial.print("leftwheel motor direction: ");
Serial.print(leftfrontback);
Serial.print("\n") ;
Serial.print("------------------------------------------") ;
Serial.print("\n") ;
delay (5000);
}
There may be an error in the code, but I cant see where it is. Here is the link to where it is on the arduino forum, If someone can see the error let me know where it is please!
http://arduino.cc/forum/index.php/topic ... #msg858136