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);
}
}