If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Motor controller

In this video we take you step by step through building the L298 Motor driver. This controller allows you to use your Arduino to control the hair dryer motors used to move the Bit-zee bot. Created by Karl Wendt.

Want to join the conversation?

Video transcript

This is our L298 compact motor driver. We're going to use it to control the motors on our little Bit-zee bot. We're going to control those hairdryer motor's speed and direction using this guy. It's going to allow us to switch the high voltage we need for the motor and the high current with our low voltage and low current from our micro-controller, which is called the Arduino. So the Arduino here has a bunch of different pinouts. We can use those to connect to the motor controller and control the motor. It also has a USB cord that we can plug in our USB socket we can plug into our computer so we can program it to tell the motor controller what to do. So the motor we're going to use is this guy. It's basically a hairdryer motor. And it's going to be used as our wheels on the Bit-zee bot. And so it'll allow us to drive around and do all kinds of things. And the motor controller allows us to control two of these. So that's one of the reasons we selected it. We also chose it because it was a kit. So to get started, we need to use rosin-core. We're using a rosin-core 60/40 solder. And the rosin core allows it to stick a little bit better. So the first thing we're going to do is select our resistors for our L298 chip. And the resistors are going to be-- those first resistor are 47k ohm resistors. And you can tell they're 47k ohm because like all resistors they have stripes on them that indicate what their resistance level is. So these particular ones are yellow, purple, orange, and gold. And so we put the resistors in and we've bent their leads so that the resistors stay snug against the board. And we're going to heat the solder pad that the resistor's lead goes through. So this takes a little while to get the hang of it, but we're just heating the soldering pads that the lead is going through and trying to make sure that they get just enough solder to wick all the way around the lead and make a clean connection. Sometimes it's tough to get the point of the soldering iron just right so that you can get the heat on the pad. But we'll get it there. And it's important to keep the tip of the soldering iron clean. So now we're inspecting the connections to make sure that they are solid and that our components are where they should be on the board. And you can see that the solder has flowed through and there's a good connection on each of the resistors. So we're going to go ahead and trim off those leads. We'll use a nipper pliers. And you want to trim them as close to the board as you possibly can. You still want to, of course, leave the solder connection intact. All right, so now we're going to install our next two resistors. And we'll do these little bit more quickly because you've already seen how we connect resistors. These resistors are 2.2k ohm resistors and they are used to protect our indicator LEDs. You can see them in the top of the screen there, the green and the red ones. And these are indicated. You can tell they're 2.2k because they're red, red, red, and gold. And so we just splayed the leads of the resistors there so we could hold them in place. And then, of course, we soldered them down. And those resistors are put in place vertically instead of horizontally because there's not as much space. All right, so now we're going to install our flyback diodes. These diodes are going to protect our circuit from a current that could come back from the motors. These diodes are the same types of diodes that you would use in, say, a bridge rectifier. It's important that they're installed in a particular way. So you can see there's a little square on the right-hand side of the diode marking. And that square shows that you should line up the silver stripe on the diode with that square. So the silver stripes should be closest to the outside of the board. And that means that the diodes are in the correct location. And as we know, diodes function like valves and they only allow the electricity to flow in one direction. So it is important that they're installed in the correct way. You can see how that diode's not sitting quite flat, so I'm going to take my pliers and push it in the rest of the way. It's important that the components on the board sit flush. So then we'll just bend the leads out like we did with the other components and make sure they're all lined up appropriately. And it's important, again, to keep the leads away from each other. You don't want them to be touching when you solder them down. And so we're just verifying that the leads are there and that the diodes are flush against the board. And they are. And so we'll solder them in place and then add the other six diodes that are required for protecting our board. So we've got those in place and they're all soldered down. And we soldered each of the pads. And so now we're just going to trim off the leads. And again, you want to make sure that the solder pads don't connect to each other. They should stay separate. Anyway, we're verifying now that the solder joints look pretty good and the components are in the right orientation. And they are. So you can see how they're connected and how the solder has flowed around all of the leads and that none of the solder joints are touching. OK, so now we're going to install a filtering capacitor. This is a high-frequency filtering capacitor. It's 0.1 microfarads. And it's bipolar, which means it can be installed either direction. It's not like the diodes that care which way they go. And so we're going to bend the leads out here on this, and again we'll just heat up those solder pads and solder right to the pads. Now the pads are close on that one, so you got to be careful not to use too much solder. And we'll trim the leads off. So now we are going to install our light-emitting diodes. These light-emitting diodes are going to allow us to see what direction the motor is turning and what direction the current is flowing. All right, so these indicator diodes are very important. It's very important that they're installed in the correct way. So they have a long lead and a short lead. And this short lead needs to go towards the square pad or through the square pad. And there's also a flat side on the diode that will line up with a flat side on the opposite diode. And that's how you know that you have the diodes in in the correct orientation. And they will also sit completely flat on the board, as you can see right there, when they're in correctly. So just make sure those two short leads are facing one another and that they go through the square pads that are in the center. So again, we're going to bend those leads out and that just holds the diodes flat while we solder them in place. OK, now that we've got the diodes in, we're going to connect our interface socket strips. These basically allow us to easily connect wires from our Arduino to the motor controller. And they allow a little place for us to plug the wire in. So we're going to tape these down because they're not easy to hold in place. Their leads aren't long enough to bend. And then we're going to set them on the pliers to hold them in place, and then we'll just solder them down. So now the next step is to connect our terminal blocks. So the terminal blocks will allow us to connect our motors right to the L298 controller board and will also provide us a place to get power from the board to power other components. So we've got a place to do that. So here's where we wire our battery. That's our three-terminal block. And then our motors are wired on the two-terminal blocks. And again, we're taping those down just to make sure they sit flush, because they have a tendency to sort of fall out of the board when you're soldering them in place. Here's an electrolytic capacitor. So now we're going to install our 22 microfarad 50-volt capacitor. This is an electrolytic capacitor. The round pad needs to be connected with the positive, which is the longer capacitor lead. It is polarized. And now we have our 5-volt regulator. This is going to allow us to get five volts from the board. And we just pushed it through and we're soldering the pads down. And that 5-volt regulator will allow us to use some of the power from the board of power our Arduino. And so now we've got our L298 chip, which is the logic chip on the board. And the L298 chip interprets the signals from the Arduino and allows the power to flow to the motors. And so the L298 chip is really the heart and soul of the motor controller. So it can only go in in one direction. And when you put the L298 chip in, you want to make sure all the leads stick through an even amount. And so what I like to do is put something under the other side of the motor controller just to make sure that the pins are all coming through evenly. And so it also makes it a little easier to solder to. And again, we're just soldering right to the solder pads, heating the solder pads and connecting everything. All right, so we're double checking to make sure there are no shorts and that all the solder connections look solid and are good. And it looks like they are. So that's a good sign. And you can see there are no places where the solder has gone and connected across. And then you can see the top of the board all the components are sitting flush and they're in their correct locations. And that's pretty much it. That's our L298 motor controller that we're going to use to drive the motors on our Bit-zee bot.