This tutorial was featured on the official Arduino blog on 3/9/2011
This week, we’ll finally be using the Arduino to control some motors! First up, we’ll control a standard DC motor running off a 9V battery with the help of an NPN transistor and a PWM (Pulse Width Modulated) signal from the Arduino. Next, it’s onto 180 degree servo motors, which we will power on an independent 5V rail using a voltage regulator. We’ll control the servo using a PWM signal from the arduino, and I’ll show you how you can turn analog distance readings into precise angles for the servo to turn to!
I mention in the video that you can control DC motor direction using an H-Bridge. If you want to wire that up, take a look through this Wikipedia article, and read through this tutorial.
If you want to learn more about analog input filtering in software, check out this example code.
The Arduino Contest has been extended! So don’t forget to submit your project.
You can download the files associated with this episode here:
Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.













May 10, 2013 at 10:26 am
I made a small circuit with 4 motors and 2 servos and a high power battery.
I used a NPN transistor with the motor as you showed in the video, but I didnt install a capacitor in the circuit, is it necessary for the circuit to work?
At the moment without the capacitor the servos start vibrating and jerk as soon as I connect the battery to the circuit, I also used a voltage regulator to make a 5V line for the servos from the 9V battery.
Thanks
Pingback: Arduino Motors and Transistors -Arduino for Projects