First off, what is an H-Bridge actually?
Simply said, it is a circuit that allows you to control a DC motor’s direction, and optionally the speed as well.
A simple schematic is shown below-


The circuit as shown here (Schematic 1) is quite a ‘dangerous’ circuit as you can imagine, closing S1 and S2, or S3 and S4 simultaneous, it causes shorting the power supply (VCC to Ground).
An alternative circuit to prevent this is shown on the right (Schematic 2).
There is a disadvantage though using the alternative schematic as it does not allow the motor not to be connected at all (free run).
So, continuing using Schematic 1, we can see there are 5 possible functional states-
All open => Free
S1 and S3 closed => Brake
S1 and S4 closed => Turning right
S2 and S3 closed => Turning left
S2 and S4 closed => Brake
Instead of controlling all switches individually (which will still have the possibility to cause a shortcut), we can also use three input signals that translate to these 5 possible states.
Enable signal, Left and Right. Using the truth-table below shows how these three signals control the H-Bridge. Please note that M1,2,3,4 do not correspond with S1,2,3,4 shown in Schematic 1, this relates to an H-Bridge circuit we have built separately.
We have built a Raspberry Pi HAT that can control up to four H-Bridges using this method. This is going to be made available soon through our Webshop.
In the meantime, please contact us if you have any questions.
Reference: https://en.wikipedia.org/wiki/H-bridge