How do I connect an H bridge to arduino?

Hi, I want to make a 12V DC motor work with a joystick, but when I connect the h bridge to the arduino and I move the joystick, hte motor does not move. My h bridge has LED to I can see that the code is not the problem. This is how I have connected it:

Does anyone know why this does not work?
Thanks

Post your code. Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

What is the motor power supply? Volts? Amps?

Post the motor data sheet.

Have you tested the motor by connecting it directly to the same power supply that your circuit uses?

Yes I have and it works.

Maybe it's the code. Oh, you say the LED lights. Do you have the right motor connections to the bridge?

int speedPin = 11;
int dirPin1 = 12;
int dirPin2 = 13;
int speedMotor;
int dt = 100;
int dt2 = 5000;
int yPin = A1;
int yVal;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(speedPin, OUTPUT);
  pinMode(dirPin1, OUTPUT);
  pinMode(dirPin2, OUTPUT);
  pinMode(yPin, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  yVal = analogRead(yPin);
  Serial.println(yVal);

  if (yVal > 550) {
    speedMotor = map(yVal,550,1023,0,255);
    digitalWrite(dirPin1, 0);
    digitalWrite(dirPin2, 1);
    analogWrite(speedPin, speedMotor);
  }
  if (yVal <= 550) {
    speedMotor = map(yVal,550,0,0,255);
    digitalWrite(dirPin1, 1);
    digitalWrite(dirPin2, 0);
    analogWrite(speedPin, speedMotor);
  }

}

The motor works with 12 volts

Is the board shown the same as the one you are using? Is this a real circuit, or only a simulation?

What yVal values do you see on the Serial Monitor? Maybe try mapping to range 50-255.

The arduino board is the one that I am using, but the h bridge is different, this are the 2 that I have:

Thanks, I will try this as soon as posible

Since your original diagram is revealed to be fictional, please post a real one. Please also provide clickable links to technical information about all the actual hardware you're using.

You said you have two different motor boards, but not which one(s) you're actually using. Can you see how that might be confusing?

I am using the first board and my diagram is actually the circuit that I have done, just that I can't put the exact same board model, but they both work on a similar way.

Yes, I have the right connections, they are the ones showed on the diagram

Please read the forum guidelines to learn what is required to ask a question here.

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