If you also want to control the speed of the motors, you should connect it to PWM ports to enable pin of module.īelow truth table show the various modes of operation Now, you have the ability to turn the motor on in both directions.
applying both pins to LOW or both to HIGH will stop the motor. If you want the motor A to rotate in one direction, apply a HIGH pulse to IN1 and a LOW pulse to IN2.įor motor B, you should apply HIGH and the other one LOW the motor should rotate as per your logic. Input 1 and input 2 control motor A, and input 3 and 4 control motor B. The input pins control the direction the motors rotation. However, note that for small duty cycles, the motors might not spin, and make a continuous buzz sound. The motor speed is proportional to the duty cycle. If you send a PWM signal, you can control the speed of the motor.If you send a LOW signal to the enable 1 pin, motor A turns off.If you send a HIGH signal to the enable 1 pin, motor A is ready to be controlled and at the maximum speed.The enable pins are like an ON and OFF switch for your motors. Now, that you’re familiar with the L298N Motor Driver, let’s see how to use it to control your DC motors. The input pins are used to control the direction of your DC motors, and the enable pins are used to control the speed of each motor. If you supply more than 12V, you should remove the jumperĪt the bottom right you have four input pins and two enable terminals.
Jumper removed: you need to provide 5V to the +5V terminal.
#L298n motor driver how to connect to arduino series
A common technique for doing this is to use PWM (Pulse Width Modulation) PWM is a technique where average value of the input voltage is adjusted by sending a series of ON-OFF pulses. The speed of a DC motor can be controlled by varying its input voltage. DC Motor Controlling can be achieved by combining these two techniques. In order to have a complete control over DC motor, we have to control its Speed and Rotation Direction. Coupling the L298N H-Bridge to a microcontroller like an Arduino Uno, ESP32 board will give you the ability to control both the speed and rotation direction of two DC motors. The L298N H-Bridge module is a simple way to achieve that. In this tutorial, we will learn How to control DC motor with ESP32 using L298N-Bridge Motor driver ?.