Content on this site may not be resold or reproduced. Copying is strictly prohibited. This post may contain affiliate links. See the Affiliate Disclosure for more information. Use of information on this site is at your own risk. View the Terms of Service.
If you've ever tried to build a mobile robot, then you'll need to learn how to program motor controllers. In our Beginner Bots tutorials, we use the L298N motor controller with the Arduino Uno to drive four motors. You can pick up a Smart Robot Car and follow along with this article if you'd like! For this tutorial, I'm going to show you how to translate motor controller specifications into Arduino code. First, we will take a look at the L298N Motor Controller Specifications. Typically the manufacturer will include a truth table outlining key functionality. I've moved a copy of the L298N truth table below, for your reference.
Next, we will create global variables for each of the motor pins. There are three pins per motor, so we will map each pin to a global variable. In the setup() method, we'll declare each pin as an OUTPUT using th…
About Liz Miller
Creator of LearnRobotics.org. Liz is a Robotics Engineer with experience ranging from Robotics Research at UPenn, Teaching at MIT, and Automated Manufacturing Engineering at United Technologies. Liz writes technical tutorials that anyone can follow and provides tips and tricks to help engineers grow their careers. Liz has authored over 100 pieces of unique content on this site. You can support her work here. Learn more about Learn Robotics on our About Us page.
You may also like
Welcome to Learn Robotics!
I’m Liz, a Robotics Engineer, and the creator of Learn Robotics.