motor codeing

hi i have arduino mega and motor driver, the problem is i cant put both motor at CW(both will not rotate in that condition). other condition works fine.
here is the code.

#define CW  0
#define CCW 1

#define MOTOR_A 0
#define MOTOR_B 1

const byte PWMA = 3;  // PWM control (speed) for motor A
const byte PWMB = 11; // PWM control (speed) for motor B
const byte DIRA = 12; // Direction control for motor A
const byte DIRB = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(PWMA, OUTPUT);
  pinMode(PWMB, OUTPUT);
  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);
  
  // Initialize all pins as low:
  digitalWrite(PWMA, LOW);
  digitalWrite(PWMB, LOW);
  digitalWrite(DIRA, LOW);
  digitalWrite(DIRB, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  driveArdumoto(MOTOR_A, CW, 255); 
  driveArdumoto(MOTOR_B, CW, 255);
}
void driveArdumoto(byte motor, byte dir, byte spd)
{
  if (motor == MOTOR_A)
  {
    digitalWrite(DIRA, dir);
    analogWrite(PWMA, spd);
  }
  else if (motor == MOTOR_B)
  {
    digitalWrite(DIRB, dir);
    analogWrite(PWMB, spd);
  } 
}

what driver? how are things powered?

Hi,
How many problems do you have with this prject?

If they are all the one project, then only have one thread and get your problems sorted out in a logical matter.
Having two or three threads running will mean confusion when code changes are made from different sources.

the problem is i cant put both motor at CW(both will not rotate in that condition). other condition works fine.

If you cannot get both of them rotating CW, what do they do?
What other condition?

Thanks.. Tom.. :slight_smile:

I mean (CW,CW) will not rotate.
(CW,CCW),(CCW,CW),(CCW,CCW) work well.

Cf question 1... but if you have multiple threads on this I'm not interested in digging everywhere... ask moderator to merge threads

Hi,
What motor driver are you using?
Link to data, please?

Thanks… Tom… :slight_smile:

ardumote shield

Hi,
Have you tried the Example code from the Sparkfun site.
How are you powering the motors?

https://learn.sparkfun.com/tutorials/ardumoto-shield-kit-hookup-guide

Tom... :slight_smile: