Control 4 H-bridges using 2 HC595 Shift registers

Hi,

I am trying to build a project where I need to use four H-Bridges L298N and two 74HC595 shift registers just for the purpose of reducing the number of wires used to control the bridges. So, far I have tried to modify an open source code done for controlling the brightness of LEDs, though no results. The issue is that I have not succeeded in controlling the shift register to Output PWM signals separately per each H-bridge.
would be thankful if someone would suggest/lead to a solution for completing the code.

thanks!

Why do you need PWM for a h-bridge?

Do not post .ino files as most mobile devices will not be able to read them.

Please read the how to use this forum sticky post.

I need PWM signal to control the speed of the motors, is any other way to do that?

You only need one PWM signal per h-bridge so you can use one of the ones on the Arduino and the other from the shift register. Otherwise you can get an external board to generate PWM.
Using a shift register will work as well. If you posted your code correctly we might be able to see where you are going wrong.
See the how to use this forum sticky post.

I thought you wanted to control h-bridges, why all the talk of brightness in the code?

Yes, you are right, in the code the there is this 'brightness' variable that sets the output power for LEDs, but it gives a similar output for the H-bridges to control them (variable voltage).

but it gives a similar output for the H-bridges to control them (variable voltage).

Well it is not a variable voltage it is a variable duty cycle rectangular wave:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Motors take way longer to respond to speed control than LEDs take to respond to brightness. So that 20mS delay is just going to bypass the motor.

How have you wired it up, please supply a schematic.

Hi again, sorry for late reply. I agree with you regarding PWM signals. As for the schematic, here I post a general picture of my setup and its operation concept for motor speed and direction control.

You need to connect the negative of your motor's power supply with the Gnd of the Arduino to stand any chance of it working.

As for the schematic, here I post a general picture

That is a physical layout diagram and as such is useless for checking all but the crudest of mistakes. You certainly can't see what shift register outputs you have set or clear to get the required control. Plus you don't seem to have any ceramic power supply decoupling capacitors on those shift register chips.