Controlling DC Motors with the L298N H Bridge and Arduino

1,304,509
314
2017-03-11に共有
In this video, I'll show you how to use the L298N H-Bridge Motor Controller with an Arduino. Includes plans for a simple robot car.

Get more info about using the L298N at dronebotworkshop.com/dc-motors-l298n-h-bridge/
More articles and tutorials: dronebotworkshop.com/
Join the conversation on the forum: forum.dronebotworkshop.com/
Subscribe to the newsletter and stay in touch: dronebotworkshop.com/subscribe/

The L298N Dual H-Bridge Motor Controller is an inexpensive device that allows you to control two independent DC motors using 5-volt digital logic signals, such as the digital output pins of an Arduino. The L298N can also be used to control a single stepper motor or two sets of LED lighting strips.

In this tutorial, we'll learn how to control two 6-volt DC motors with the L298N.

First, we will enlighten ourselves by learning a quick bit of the history of DC motors and discovering how they actually work. We will also learn what an “H-Bridge” is, how it works, and how we can control the direction of rotation of a DC motor with it.

We will then quickly discuss the concept of Pulse Width Modulation, or PWM, as it is used to control the speed of DC motors. Don’t worry, it’s a lot easier than it sounds!

Then we will look at how the L288N H-Bridge module actually works, how to hook it up to a couple of motors, and how to power it correctly.

Next, we will connect the L298N Dual H-Bridge Motor Controller to an Arduino. Once that's done we’ll run a motor demo sketch to put the device through its paces.

After the demo, we will expand upon our sketch to allow a couple of potentiometers (connected to the Arduino’s analog inputs) to control the speed of each motor.

And now that we’ve become experts we will replace the potentiometers with a joystick and use it to control the motors. Just for fun, we’ll use this setup to build an Arduino-driven car!

The L298N Dual H-Bridge Motor Controller is a very versatile device that is sure to find a lot of use in your robotics and IoT projects. Anywhere you want to make things move with an Arduino!

This is a long video, so if you’d like to jump ahead to a specific spot here is the table of contents:

00:00 - Introduction
01:25 - What is a DC Motor & Where is it used?
03:01 - How does a DC Motor work?
04:17 - What is an H-Bridge?
05:25 - Popular L298N Interface boards
06:49 - L298N Module Pinouts and hookup
09:04 - Understanding PWM (Pulse Width Modulation)
09:58 - Testing the L298N without a controller
13:28 - Arduino Hookup to L289N
14:53 - Sketch 1 - Motor Control Demo
19:29 - Motor Control Demo
20:38 - Potentiometer Hookup to Arduino and L298N Module
21:38 - Sketch 2 - Two Potentiometer Control Demo
25:08 - Two Potentiometer Control Demo
25:43 - Joystick and Arduino Hookup
27:52 - Sketch 3 - Joystick Control Demo
34:22 - Driving our car!


For more information and other great projects and tutorials please visit dronebotworkshop.com/ .

And if you enjoyed this video please like it and subscribe to the DroneBot Workshop YouTube channel!

コメント (21)
  • Your channel is severely underrated, you explain things very concisely, as someone with very little knowledge of electronics, I appreciate your work.
  • Nicely done. Very easy to understand and follow your sketches. You have a rare ability to explain the concepts in an easy to understand way without talking down to your audience. Thank you and hope to see much more.
  • Your videos are outstanding and greatly appreciated, especially to a newbie like me. My original intent was to build the robot following your “Build a Robot” series but up to video #5 I realized it was somewhat more than I could do, so I’ve opted to learn and build from your individual robot videos (baby steps). I am familiar with ac electrical power which helps when working with dc. I’ve built a few of your examples, following the instructions, including all on this video, using the Arduino and motor controller and none of them functioned initially. Reading the comments from your other followers made me believe it was something I was doing wrong. I purchased all the same equipment and followed your instructions (I think). But this actually turned out to be a blessing. I was forced to read and learn about Arduinos, motors, motor controllers, etc. and not just piece pieces of equipment together and copy code. For instance, in this video with regards to using a joystick. Following your instructions, I was able to get motor B to turn in one direction, nothing else. Moving the enable pin for motor A to #2 on the Arduino and the data pins to #6 and 7, then updating the code, everything is functioning fine. Having to make these adjustments I hope is not a result of me doing something incorrectly as far as your instructions. (Maybe the equipment is not created equal?)
  • @Nelsonswl
    wow this guy is brutally descriptive, I love this channel already i wish i could give this video a 1000 likes. now i understand what is PWM. this video hit the spot on my quest for knowledge. Keep making videos like this, i have subscribed.
  • great video as usual. love the way you systematically divide larger projects up into functional nibblets and then concisely and clearly communicate them with sufficiently high production value. keep it up !!
  • Where have you been in my entire arduino experience(almost 2 yrs)!! lol i have been trying to figure out how to drive 2 motors with 2 joysticks individually for a tank build and you helped me figure it out from watching your demos and codes!!! Thank you so much and please keep the videos coming. Liked and Subscribed.
  • Great Video mate! I've been through many other tutorials regarding the same topic but none was as informative and understandable as yours is. Keep more coming, Thanks! Subscribed!
  • Absolutely outstanding video! you didn't skip any detail while keeping it professionally presented. Thank you so much for this <3 liked and subbed.
  • 2nd time i end up on your channel, 2nd time i'm impressed by the quality and clarity of the information. nice work!
  • @jdoc99
    This is the explanation I have been looking for. You covered all the little details thoroughly enough to give a newbie like the confidence to get started. I'm so happy I found your channel.
  • To skip values < 9, you can speed=map(speedStick, 0 1023, -247, 247); the same as below, and analogWrite (enable 8+abs(speed));
  • @Lunolux
    nice video, every time i'm saying in my head "i wont finish your video because it's too long" but it's very nice video every time, well explain
  • Professional, well organized , awesome. This video tought me more about DC motors and controlling them than my university did. Thank you !
  • Hello Dronebot Worshop. Informative, interesting and well delivered. I think you have a potentially large audience of people like me who may not have an electronics or programming background but who are interested in learning about arduino, raspberry pi, ect. Thank you for the video, hope to watch more from you soon.
  • Excellent explanation, organised and great presentation skills. You deserve a huge following, keep it up please it is greatly appreciated!
  • You are the best instructional video maker on the internet. Believe me, I've looked. You are truly a treasure.
  • This is one of the most informative videos I have seen on the web. Also same goes for your blog. Thank you very much for sharing this much information.