This depends on the voltage used at the motors VCC. The module has two screw terminal blocks for the motor A and B, and another screw terminal block for the Ground pin, the VCC for motor and a 5V pin which can either be an input or output. Let’s take a closer look at the pinout of L298N module and explain how it works.
The module can drive DC motors that have voltages between 5 and 35V, with a peak current up to 2A.
The L298N is a dual H-Bridge motor driver which allows speed and direction control of two DC motors at the same time.
There are many DC motor drivers that have these features and the L298N is one of them. So if we combine these two methods, the PWM and the H-Bridge, we can have a complete control over the DC motor. 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.
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. * * Created by * * This example code is in the public domain * * Tutorial page: */ # include # define DEG_PER_STEP 1.In this Arduino Tutorial we will learn how to control DC motors using Arduino. Therefore, we need a hardware driver in between Arduino and the stepper motor. However, the signals from Arduino do not have enough voltage and/or current that the stepper motor requires. How to control a stepper motor using ArduinoĪrduino can generate signals to control the stepper motor. STEP_PER_REVOLUTION = (360 / DEG_PER_STEP) * nįor example, If the motor's datasheet specifies 1.8 degree/step: Control method STEP_PER_REVOLUTION = (360 / DEG_PER_STEP) * 2 Depending on the method of control, the steps per revolution (let's call STEP_PER_REVOLUTION) is calculated as the following table: Control method The motor's specification specifies the degree per step (let's call DEG_PER_STEP). The above image also shows the specification of two different motors with different wire naming and wire coloring.
You need to read the datasheet or manual to see the mapping between wire color and pin name. The order of pins, wire naming, and wire coloring can vary between manufacturers.