Struggling with DC Motor Controller

Hi. I'm struggling with a DC Motor. (I'm new at this).

No matter what I do, my DC motor only turns CW - and not when it's supposed to. See my comments on actual results inside my code.

Hardware setup:

Arduino Mega R3 with power from USB.
DBH-12V Motor controller.
Small 12V DC motor.

Currently 100% of the power is coming from the USB. (5V+/- jumpers from Mega to Motor controller. Then motor plugged into Motor A on the controller).
Ultimately this will all be setup on a 12V battery but am still troubleshooting.

It seems like maybe the controller is misunderstanding the HIGH/LOW signals from the controller? Can (or should) I somehow redefine the outputs from the Arduino? I'm super confused.

I'm especially struggling because I can't find any documentation on this motor controller. (But I needed to select it because it had a higher amp rating which I need for my project).

See my test code below.

//Outputs for my motor.
int motor1pin1 = 5;
int motor1pin2 = 6;
int enA = 4;

void setup() {
// put your setup code here, to run once:

pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(enA, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:

//Actual result from code below: Motor turns CW slow for longer duration.
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
analogWrite(enA, 125);
delay(1000);

//Actual result from code below: Motor stops.
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, HIGH);
analogWrite(enA, 250);
delay(1000);

//Actual result from code below: Motor turns CW fast for short duration.
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
analogWrite(enA, 250);
delay(250);

//Actual result from code below: Motor stops.
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
analogWrite(enA, 150);
delay(1000);
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the </> icon above the compose window) to make it easier to read and copy for examination

Please use code tags when posting code, and post a hand drawn wiring diagram.

Triple check your wiring, and keep in mind that breadboards are not designed for motors. The tracks will burn due to the high currents.


The pictures are uninterpretable. Forum members need to see a wiring diagram.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.