How many time do you want to control a dc motor in both directions with control of the rotation speed. It can be done with a H bridge, but a couple of times we haven’t controlled very well the input signals and we have burned the bridge.
So in this project we will use two relays and one transistor for PWM. The relay must have the SPDT(single pole double throw) pin configuration.
The relays used by us are with coil at 12 Vdc. So for that we can’t power it direct from arduino but we will use one transistor for each relay.
In images below are images with relay and pin diagram:
Ok, before to control with PWM let’s see how to change the rotate direction of a dc motor with two relays like the one above:
Now in the diagram above when you power on the R1 relay the motor will rotate in one direction, and if power off R1 and power on the R2 the motor will start in the opposite direction.
The advantage of this method is that if you power on the R1 and R2 the same time the motor is not poweredand nothing burns:)). To control the relays we use two 2n2222 npn transistor and a 1 kohm resistors.
When the arduino pins which are connected to transistors are HIGH the relay will be powered.
Now to control it with PWM on both directions we will mount a transistor on the ground(“-“) side(also npn) like:
As yo can see for any configuration of relays, the ground terminal remain the same and control the speed of the dc motor through PWM. Because we use a small dc motor in example for PWM we have another 2n2222 transistor with 1kohm resistor to polarize it. If you have a bigger dc motor use a suitable transistor.
The parts mounted on a breadboard looks like:
As you can see we used a 7805 voltage regulator to power arduino(of course you can use a jack and eliminate the voltage regulator ) from the 12V source used for relays, and 1kohm potentiometer to control the motor with PWM.
The program used in video you can download from here.
Please let us in the comment zone any suggestions that you think will improve the article!
If you like the article click the follow button from social media to stay in touch with us!
A short video: