![l298n motor driver board arduino sketch l298n motor driver board arduino sketch](http://www.14core.com/wp-content/uploads/2015/07/L298-DUAL-H-BRIDGE-MOTOR-DRIVER-Schematics-Diagram.jpg)
So if we combine these two methods, the PWM and the H-Bridge, we can have a complete control over the DC motor.
![l298n motor driver board arduino sketch l298n motor driver board arduino sketch](https://m.media-amazon.com/images/I/71btu5f97fL._AC_SL1001_.jpg)
By activating two particular switches at the same time we can change the direction of the current flow, thus change the rotation direction of the motor. An H-Bridge circuit contains four switching elements, transistors or MOSFETs, with the motor at the center forming an H-like configuration. On the other hand, for controlling the rotation direction, we just need to inverse the direction of the current flow through the motor, and the most common method of doing that is by using an H-Bridge. Note: Arduino GND and the motor power supply GND should be connected together. The low power Arduino PWM signal switches on and off the gate at the MOSFET through which the high power motor is driven. So depending on the size of the motor, we can simply connect an Arduino PWM output to the base of transistor or the gate of a MOSFET and control the speed of the motor by controlling the PWM output. The average voltage depends on the duty cycle, or the amount of time the signal is ON versus the amount of time the signal is OFF in a single period of time. PWM, or pulse width modulation is a technique which allows us to adjust the average value of the voltage that’s going to the electronic device by turning on and off the power at a fast rate. We can control the speed of the DC motor by simply controlling the input voltage to the motor and the most common method of doing that is by using PWM signal.
L298n motor driver board arduino sketch how to#
We well take a look at some basic techniques for controlling DC motors and make two example through which we will learn how to control DC motors using the L298N motor driver and the Arduino board. In this Arduino Tutorial we will learn how to control DC motors using Arduino.