Getting motor to stop

It runs continuously instantly when powered on

So you need some test code, JUST to run the motor, to prove you have the connections correct.

Tom.. :grinning: :+1: :coffee: :australia:

Hi,
Try this code, it is an edited copy of your code.
It just makes the motor stop/fwd/stop/rev in a cycle.
I'm not sure which output of the driver board you have you motor connected to, so this code does both outputs.
This means your motor should go through a cycle, then stop for about 5 seconds then cycle again.

// Controller pins
const int CH_2_PIN = 3;


// Motor driver pins
const int STBY_PIN = 7;
const int AIN1_PIN = 12;
const int AIN2_PIN = 11;
const int APWM_PIN = 10;
const int BIN1_PIN = 1;
const int BIN2_PIN = 2;
const int BPWM_PIN = 5;


// Parameters
const int deadzone = 40;  // Anything between -40 and 40 is stop


void setup()
{
  // Configure pins
  pinMode(STBY_PIN, OUTPUT);
  pinMode(AIN1_PIN, OUTPUT);
  pinMode(AIN2_PIN, OUTPUT);
  pinMode(APWM_PIN, OUTPUT);
  pinMode(BIN1_PIN, OUTPUT);
  pinMode(BIN2_PIN, OUTPUT);
  pinMode(BPWM_PIN, OUTPUT);
  // Enable motor driver
  digitalWrite(STBY_PIN, HIGH);
}


void loop()
{
  // Limit speed between -255 and 255
  analogWrite(APWM_PIN, 250);
  analogWrite(BPWM_PIN, 250);
  // Test motor A
  delay(500);
  digitalWrite(AIN1_PIN, HIGH); //fwd
  digitalWrite(AIN2_PIN, LOW);
  delay(1500);
  digitalWrite(AIN1_PIN, LOW);  //stop
  digitalWrite(AIN2_PIN, LOW);
  delay(500);
  digitalWrite(AIN1_PIN, LOW);  //rev
  digitalWrite(AIN2_PIN, HIGH);
  delay(1500);
  digitalWrite(AIN1_PIN, LOW);  //stop
  digitalWrite(AIN2_PIN, LOW);
  delay(500);
  // Tset for motor B
  digitalWrite(BIN1_PIN, HIGH);  //fwd
  digitalWrite(BIN2_PIN, LOW);
  delay(1500);
  digitalWrite(BIN1_PIN, LOW);  //stop
  digitalWrite(BIN2_PIN, LOW);
  delay(500);
  digitalWrite(BIN1_PIN, LOW);  //rev
  digitalWrite(BIN2_PIN, HIGH);
  delay(1500);
  digitalWrite(BIN1_PIN, LOW);  //stop
  digitalWrite(BIN2_PIN, LOW);
  delay(500);
}

Tom.. :grinning: :+1: :coffee: :australia:

Which picture of the motor driver board are you using? The one with a red wire on B+ and black wire on GND?

The transmitter doesnt seem to be working the motor



This is what I have now

If you have two motors connected, switch the wire pairs. Does the same motor have the problem, or the other motor.

I only have 1 motor

Did the motor change behavior?

With the motor if I connect it to the battery it runs constantly, but if I connect it to the motor driver board it doesnt work. I feel like the transmitter isnt picking it up or idk

Is the motor a DC motor (a + and a - connection).
Is the board a stepper motor driver (A+/A- and B+/B-)? Can you identify the part number of the motor driver board?

The motor is a DC 12v and the motor driver model number is md35a/0J11169

Hi, @mommy2one

Have you tried my code?

Tom.. :grinning: :+1: :coffee: :australia:

Placing this here for reference to this PCB MD35A (edit... changed link to pololu)

Your code is talking to two motors... so put the 1 motor where the 2 motor would be... and see if the motor behavior changes.

Yes I did and it didnt work, apparently my code is talking to 2 motors when I only have one

Do I need to delete that part of the code too? Im not even sure which one the motor is in

Your code seems to want input from the flysky on pin 3, then translate that input into motor movement, then send that translation to both motors.

If TomGeorge's test failed. Check all wiring. I made a simulation to show his code:

If you want to see your code in action, look at this video, starting at 16:00... you will see that your code is lacking a channel (you have one: CH_2).

Hi,

It should not have mattered if you have one or two motors connected, the motor I would think should have run.

What wires are these red and black?
Motor or power supply for the motor.


If motor or power supply, it is wrong.

Motor supply is between VIn and gnd.
Motor should be connected between B+ and B- or between A+ and A-.

PLEASE get out pen(cil) and paper and post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Tom.. :grinning: :+1: :coffee: :coffee: :coffee: :coffee: :australia:

Tom.. :grinning: :+1: :coffee: :australia:

Here is a simulation of your code, using a potentiometer as the Flysky.