https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/ ► Find more details, circuit schematics and source codes on my official website.

In this Arduino Tutorial we will learn how to control DC motors using Arduino. 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 driver and the Arduino board. 

If you enjoy and find the content that I make useful, please consider supporting me on Patreon: https://www.patreon.com/howtomechatronics

Parts list (check website article for full list, affiliate links):
Amazon.com:
L298N Driver: https://amzn.to/2KwGM0o
12V High Torque DC Motor: https://amzn.to/2HoYuUe
Arduino Board: https://amzn.to/2Ccd5kC

Banggood.com:
L298N Driver: http://bit.ly/3c7tOY4
12V High Torque DC Motor: http://bit.ly/39eup8s
Arduino Board: http://bit.ly/2YioMjH

Visit HowToMechatronics.com for more Tutorials, Tips, Projects and How It Works videos:
► https://howtomechatronics.com/

Like my page on Facebook:
► https://www.facebook.com/howtomechatronics

, https://i.ytimg.com/vi/I7IFsQ4tQU8/hqdefault.jpg

source

23 Comments

  1. Can we run 4 motors using this L298N driver?if YES then how can we connect this motors to the L298N???PLZ Plz reply fast..

  2. How do you stop it from veering to one side when it should be moving straight?

  3. I'm sorry that I can't support you but i have to tell that you would deserve more for these videos.

  4. Hi, Im trying to build a similar circuit: 24v power supply with a h bridge controller for a 24v servo motor, what I'm worried about its sending the 24V (+) to the VIN Power Pin of the Arduino card (min 06:40).

  5. Very well explained.The schematics and illustrations are perfrect. Fantastic video

  6. In case someone connects the motor to A or B with ENB enabled (means motor is not PWM regulated, runs at full speed) with 12V jumper enabled and is surprised nothing happens after turning power on, there is a simple reason. Just connect a wire to 5V out, power on again and then touch either one of two pins, for example IN1 if motor is connected to A, that regulate the rotation direction (forward/backward). The motor will start turning.

  7. All of your videos deserve lot of superlative adjectives. Extremely good quality project and your explanation of theory and the Arduino sketch were precise and clear. May I suggest you do a self balancing two wheel "robot" project and cover PID in detail ?

  8. Great video and very cool, but i proved the code with my car and the same components and it doesn´t work. Can you tell me any thing for help please?

  9. How can c control a 24v, 7A dc motor with same method as discussed in the video?

  10. and how did you define the motor speed PWM as 255 when your motor`s 12V with 100rpm
    is there any calculation formula for PWM in motor speed

  11. Here is code to control 4 dc motors on tank chassis:
    int rc_pulse1=1; //reading signal from FS
    int rc_pulse2=2;
    int mpwm1=3; //PWM channels for motors
    int mpwm2=4;
    int mpwm3=5;
    int mpwm4=6;

    void setup() {

    pinMode(1,INPUT);
    pinMode(2,INPUT);
    pinMode(3,OUTPUT);
    pinMode(4,OUTPUT);
    pinMode(5,OUTPUT);
    pinMode(6,OUTPUT);
    pinMode(7,OUTPUT);
    pinMode(8,OUTPUT);
    pinMode(9,OUTPUT);
    pinMode(10,OUTPUT);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    digitalWrite(7,LOW);
    digitalWrite(8,LOW);
    digitalWrite(9,LOW);
    digitalWrite(10,LOW);
    }

    void loop() {

    mpwm1=0;
    mpwm2=0;
    mpwm3=0;
    mpwm4=0;
    delay(50);
    rc_pulse1=pulseIn(1,HIGH,25000);
    rc_pulse2=pulseIn(2,HIGH,25000);
    delay(50);
    if(rc_pulse1>1024) {
    mpwm1,mpwm2=map(rc_pulse1,1024,2047,0,255);
    if(mpwm1,mpwm2>0) {
    analogWrite(3,mpwm1);
    analogWrite(5,mpwm2);
    }
    }
    delay(50);
    if(rc_pulse1<1023) {
    mpwm1,mpwm2=map(rc_pulse1,1023,0,0,255);
    if(mpwm1,mpwm2>0) {
    analogWrite(4,mpwm1);
    analogWrite(6,mpwm2);
    }
    }
    delay(50);

    if(rc_pulse2>1024) {
    mpwm3,mpwm4=map(rc_pulse2,1024,2047,0,255);
    if(mpwm3,mpwm4>0) {
    analogWrite(7,mpwm3);
    analogWrite(9,mpwm4);
    }
    }
    delay(50);
    if(rc_pulse2<1023) {
    mpwm3,mpwm4=map(rc_pulse2,1023,0,0,255);
    if(mpwm3,mpwm4>0) {
    analogWrite(8,mpwm3);
    analogWrite(10,mpwm4);
    }
    }
    delay(50);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.