H-Bridge Circuit check?

I just want to know whether I am doing something wrong with my H-bridge circuit. I want to control both speed and direction and just want another persons opinion on whether this will control speed and direction here is the pin out:

5v is coming from the Arduino and ground is coming from Arduino
9v connected to pin 8 and ground of the H-bridge
pin 1(enable 1) of H-Bridge is connected to +5v, pin 9(enable 2) of H-bridge is connected to +5v, pin 16(Vss) of H-bridge is connected to +5v
pin 2(input 1) of H-bridge is connected to PWM 5, pin 7(input 2) is connected to pin D4, pin 15(input 4) of H-bridge is connected to PWM 6, and pin 10(input 3) of H-bridge is connected to pin D7.
pins 11(output 3), and 14(output 4) on H-bridge are connected to the terminal block motor B.
pins 3(output 1), and 6(output 2) on H-bridge are connected to the terminal block motor A.
pins 4 and 5 on H-bridge are connected to ground
pins 12, and 13 of H-bridge are connected to ground

Here is the image:

I just want to make sure I can control both speed and direction and also I don't want to burn anything out any help is awesome thanks.

the H-bridge I am using is an L293D

little bit of an update:

found out you need the PWM pin on the enable to control speed so both of the enables are connected to PWM D5 and PWM D6 and I have pin D12 and pin D10 connected to pins 1 and 15 of the H-bridge. here is that pic:

or can I tie pin 10 and pin 7 to pin 15 and pin 2? here is the pic of that:

So I think I figured this out but i still want an opinion in order to do it the second way (in reference to the post that precedes this) I would need a through hole inverter (2 of them) or I can do it with six I/O's instead of the 4. any comments would be nice thanks

ok so I have written code for this and it does not work:( here is the code: any help would be awesome.

int dir_a1 = 2;
int dir_a2 = 7;
int dir_b1 = 10;
int dir_b2 = 12;
int PWM1 = 5;
int PWM2 = 6;

void setup(){
 
 pinMode(dir_a1, OUTPUT); 
 pinMode(dir_a2, OUTPUT);
 pinMode(dir_b1, OUTPUT);
 pinMode(dir_b2, OUTPUT);
 pinMode(PWM1, OUTPUT); 
 pinMode(PWM2, OUTPUT);
  
}

void loop(){
 
 digitalWrite(dir_a1, HIGH);
 digitalWrite(dir_a2, LOW);
 digitalWrite(PWM1, 100);

 
 digitalWrite(dir_b1, HIGH);
 digitalWrite(dir_b2, LOW);

 digitalWrite(PWM2, 255);
 
 delay(2000); 
 
  digitalWrite(dir_a1, LOW);
 digitalWrite(dir_a2, HIGH);
 digitalWrite(PWM1, 255);

 
 digitalWrite(dir_b1, LOW);
 digitalWrite(dir_b2, HIGH);

 digitalWrite(PWM2, 100);
}

right now one motor runs (does not run until I add the 9v though I think this is because I need the decoupling cap) but it does not run as expected it runs in one direction at 1 speed.

figured out one problem my pins where not correct but both motors run but they do not change direction or speed

here is the code:

int dir_a1 = 10;
int dir_a2 = 4;
int dir_b1 = 7;
int dir_b2 = 12;
int PWM1 = 5;
int PWM2 = 6;

void setup(){
 
 pinMode(dir_a1, OUTPUT); 
 pinMode(dir_a2, OUTPUT);
 pinMode(dir_b1, OUTPUT);
 pinMode(dir_b2, OUTPUT);
 pinMode(PWM1, OUTPUT); 
 pinMode(PWM2, OUTPUT);
  
}

void loop(){
 
 digitalWrite(dir_a1, HIGH);
 digitalWrite(dir_a2, LOW);
 digitalWrite(PWM1, 100);

 
 digitalWrite(dir_b1, HIGH);
 digitalWrite(dir_b2, LOW);

 digitalWrite(PWM2, 255);
 
 delay(2000); 
 
  digitalWrite(dir_a1, LOW);
 digitalWrite(dir_a2, HIGH);
 digitalWrite(PWM1, 255);

 
 digitalWrite(dir_b1, LOW);
 digitalWrite(dir_b2, HIGH);

 digitalWrite(PWM2, 100);
}

Figured out another issue I was using digitalWrite instead of analogWrite for the PWM pins it still does not change speed and direction though:

int dir_a1 = 10;
int dir_a2 = 4;
int dir_b1 = 7;
int dir_b2 = 12;
int PWM1 = 5;
int PWM2 = 6;

void setup(){
 
 pinMode(dir_a1, OUTPUT); 
 pinMode(dir_a2, OUTPUT);
 pinMode(dir_b1, OUTPUT);
 pinMode(dir_b2, OUTPUT);
 pinMode(PWM1, OUTPUT); 
 pinMode(PWM2, OUTPUT);
  
}

void loop(){
 
 digitalWrite(dir_a1, HIGH);
 digitalWrite(dir_a2, LOW);

 analogWrite(PWM1, 100);

 
 digitalWrite(dir_b1, HIGH);
 digitalWrite(dir_b2, LOW);

 analogWrite(PWM2, 255);
 
 delay(2000); 
 
 digitalWrite(dir_a1, LOW);
 digitalWrite(dir_a2, HIGH);
 
 analogWrite(PWM1, 255);

 
 digitalWrite(dir_b1, LOW);
 digitalWrite(dir_b2, HIGH);

 analogWrite(PWM2, 100);
}

The problem is you keep posting photos of your circuit. It is very difficult to see what you are doing from this. That is why God invented schematics, so other people can see what you are doing. Post one of those and you might get a response.

No problem I did figure out that speed is working so PWM is fine the only problem is directionmaybe it is my code because I really do think my hardware is correct here is the schematic:

still a little messy but may be easier to understand.

thanks

Sorry that is not a schematic, that is a physical layout and still not easy to see what is going on.

ok grumpy_mike this is a messy schematic but i made sure that the pins where understandable or at least I hope this is better then the pictures.

Done everything works fine thanks for the help guys guess I just needed to see myself think:)

Thanks that is better.
Basically you have not written the code correctly. You need to put both lines to the same level to turn it off and different levels to turn it on. So where so you need to put:-
// Turn motor 1 on
digitalWrite(dir_a1, HIGH);
digitalWrite(dir_b1, HIGH);
// Turn motor 2 off
digitalWrite(dir_a2, LOW);
digitalWrite(dir_b2, LOW);
analogWrite(PWM1, 100);

Note you will not see much of a speed change unless the motor is under load.

Hey Grumpy_Mike

I must be tired or something but it turns out my hardware was correct and my software had a few glitches but as I said it works now next up adding hardware inverter

there is a load mind you not a heavy load but a gear box and i can now see the difference