help adding to this code

hi guys and gals,

after some hunting i have come across this - http://bildr.org/2012/04/tb6612fng-arduino/

which is so close to what i want to do, but i would like to add the control from a joystick to it so that i can control the direction
i would also like to ad a POT to it to be able to control the speed of the motors also,

any help here would be fantastic. or if anyone can point me in the right direction of something better to start from.

Kind Regards

Marc

Please post the code here so that we can see it easily. And please use the code button </> so your code looks like this and is easy to copy to a text editor

Also you need to tell us what the existing code does so that we can understand the changes you want to make.

…R

its from someones page after doing a ton of research for it, all it is from what i can tell is 2 dc motors and a motor controller, being pulsed back and forth

//motor A connected between A01 and A02
//motor B connected between B01 and B02

int STBY = 10; //standby

//Motor A
int PWMA = 3; //Speed control 
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction

//Motor B
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction

void setup(){
  pinMode(STBY, OUTPUT);

  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  pinMode(PWMB, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
}

void loop(){
  move(1, 255, 1); //motor 1, full speed, left
  move(2, 255, 1); //motor 2, full speed, left

  delay(1000); //go for 1 second
  stop(); //stop
  delay(250); //hold for 250ms until move again

  move(1, 128, 0); //motor 1, half speed, right
  move(2, 128, 0); //motor 2, half speed, right

  delay(1000);
  stop();
  delay(250);
}


void move(int motor, int speed, int direction){
//Move specific motor at speed and direction
//motor: 0 for B 1 for A
//speed: 0 is off, and 255 is full speed
//direction: 0 clockwise, 1 counter-clockwise

  digitalWrite(STBY, HIGH); //disable standby

  boolean inPin1 = LOW;
  boolean inPin2 = HIGH;

  if(direction == 1){
    inPin1 = HIGH;
    inPin2 = LOW;
  }

  if(motor == 1){
    digitalWrite(AIN1, inPin1);
    digitalWrite(AIN2, inPin2);
    analogWrite(PWMA, speed);
  }else{
    digitalWrite(BIN1, inPin1);
    digitalWrite(BIN2, inPin2);
    analogWrite(PWMB, speed);
  }
}

void stop(){
//enable standby  
  digitalWrite(STBY, LOW); 
}

marcjwebb:
, all it is from what i can tell is 2 dc motors and a motor controller, being pulsed back and forth

Maybe the sensible thing would be to describe in some detail what you want to happen and ignore the code you found for the moment. When we know what you want we may be able to say if that code is useful.

...R