Can someone tell me if Im doing right or wrong. I tried the H-bridge (that comes with the starterkit) with some code and a motor, but no response. So I tested the circuit H-bridge separate, see attached picture.
The red pen is my own wiring and input voltage. I put 5V on Pin1, Pin2, VCC1 and Pin8 and grounded Pin4 and Pin5. Then connect and disconnect Pin2, to and from. To turn the LED on and off, I thought. Its light is on all the time no matter if Pin2 is 5V or 0V.
Datasheet says Pin2 is the controlpin for driver 1. I tried this for the other 3 drivers, moving the connection to the other side of the circuit but didnt work either. Have I got the function wrong, or is this a malfunction circuit?
Current flows from pin 3 - 6 or from 6 - 3 through the motor, not to ground.
If IN1 and IN2 are both high or if IN1 and IN2 are both low, no current flows through the motor (or LEDs). If IN1 is different than IN2 then current will flow. IN1 high and IN2 low will result in rotation one way( green LED lights). IN1 high and IN2 low will result in rotation the opposite way (red LED lights).
I think the scheme by OP is correct (if the missing resistor is included). However it does not use the ability of the H-bridge to revert the current through the load. With a LED as load this wouldn't make any sense either. If the load is a DC motor, the full use of the H-bridge would allow the motor to run in two directions. The datasheet describes use cases where the IC is used to control a motor using half of the H-bridge (same scheme as OP), with two motors controlled on right hand side of IC and one on left hand side of IC (this motor has full H-bridge). The motors with half H-bridge control can only run in one direction (assuming no mechanical input on the motor from outside).
The OP original circuit shows a LED driven with a half bridge. My impression was that he wanted to investigate a H-bridge. Hence the circuit with 2 LEDs.
The difference is the terminology. The H-bridge requires 2 half bridges.
Correct. I wanted to see if the bridge is damaged, therefore testing each driver (OP) one-by-one. As I understand the Pin2 (with high and low) should be able to turn on and off the diode, if the bridge is working? I tried this for the other side as well, the second bridge.
But what happened was that the diode stayed at high, light on, all the time. No matter if controlPin2 or the other controlpins are switched 1 or 0. I use 5V and zero V.
I lifted the wire with 5V off and then back into Pin2 again, repeatedly to see if the diode flashed on and off via the driver (OP). But all I had was the constant light on.
Build_1971 gave you a hint. There may be a pullup involved, so the input will be at 5V with or without your 5V wire. Pull the input (pin 2) directly to ground, or to 5V. See if that works, if so, your half bridge is good. If the LED stays on, you've fried that part of the bridge, and it's now full-on, all the time.
@camsysca is right. The inputs need to be either at +5V or grounded. Otherwise they float high. Not a good idea to depend on a floating input to be stable, though, so tie it high or low.
Each half bridge can either source current (be a path from Vmotor) or sink current (be a path to ground) depending on the state of its input. An input to ground makes the half bridge a current sink. A input at 5V makes the half bridge a current source.
I think they do not have an internal pullup/pulldown. But if not connected they do float. If you touch them you can switch state... So indeed, tie to zero if you want it low.
I tried the Pin2 wire in ground, and that blacked out the diode, like you say. Maybe a big pulldownresistor on Pin2 would do the trick to manage a real LOW when the 5V is gone.
If there is no pullup resistor in the IC, 20 kOhm to ground should be sufficient.
If you use a PWM output of arduino you should not need this. A small resistor in series may do no harm (and protect the output from overcurrent in case of a short).
To see if the bridge is functional, use a 220 ohm resistor and a two-lead bipolar LED(Red/Green common, other colour mixes available). That verifies that both drivers are functional.
I have now tried your tips and it works. I put on grounded 20k ohms on the controlpin 2 parallell with the switch for control, see picture. I also had to ground Pin1 via 20k ohm, to make it possible to turn on and off the whole bridge.
Trying Camsyscas tip on using both drivers 1 and 2 (driver2 not wired in picture) with grounded pins, it lighted two LEDs in a controllable maner like desired. I also tried the two directional motor from the starterkit to Pin3 and Pin6, and it turns left and right like wanted when using the controlpins.