When A is LOW and B is HIGH, transistors Q1 and Q4 are on, allowing current to flow through the motor in a particular direction. The two control inputs A and B in the previous circuit determine the direction of rotation of the motor. By activating two particular transistors at the same time, we can control the flow of current through the motor and hence the direction of rotation. The name “H-Bridge” refers to the look of the connection consisting of four transistors and a motor in the center forming the letter “H”.Ī simple H-Bridge connection using four transistors and a motor is shown below. To change the direction of rotation without inverting the motor cables every time you need to use a special circuit called H-bridge.Īn H-Bridge is a simple electronic circuit consisting of four switching elements like transistors (BJT or MOSFET) that can drive a motor in both the directions without switching the leads. This circuit is good for controlling the speed of the motor, but not for effectively changing the direction of rotation. gradually increases the speed to peak and then gradually decreases the speed to halt.įor (motorSpeed = 0 motorSpeed = 0 motorSpeed -= 10) Using this code, the Arduino will vary the speed of a DC Motor in a fading fashion i.e.
The code is given below for above circuit. The following image shows a simple circuit diagram, where a PWM output from Arduino is given to a MOSFET and the 12V DC Motor is connected through the MOSFET. The PWM Signal from any source like Arduino in this example, can be given to the gate of a MOSFET and depend on the duty cycle of the PWM Signal, the speed of the DC Motor will vary.
The duty cycle is usually expressed as a percentage, and the following figure shows several PWM signals from a 12V supply with different duty cycles of 0%, 25%, 50%, 75% and 100%, respectively. The working cycle of a PWM signal is nothing more than the ratio of the time the signal is activated or is HIGH to the total duration of the signal, that is, the time signal. Now, the average voltage applied to the DC motor depends on what is known as the work cycle of the PWM signal. The pulse width modulation or PWM signal generated by this technique allows us to control the average voltage delivered to the DC motor. If you want to control the rotational speed of a simple DC motor, there is a technique called PWM DC motor control. It is very easy to use: connect the two motor cables to the two terminals of a battery and that's it! Your motor starts spinning. Here we have different ways how to control a DC Motor and also this is quite popular for many reasons which are Arduino DC Motor control using L298N.Ī DC motor is the simplest motor that beginners and hobbyists know. In this Arduino project having main components are Arduino kit, DC motor L298N Motor Drive IC.