O'Reilly logo

Arduino Development Cookbook by Cornel Amariei

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spinning motors both ways

It's very simple to control a motor with a transistor. However, spinning the motor in just one direction is not always that useful. It's just half of what is possible. Most DC motors can spin both ways. When we apply the voltage in one direction, the motor will spin on one side. If we reverse the voltage on the terminals, the motor will spin the opposite way. But how can we do that with the Arduino? We need to use an H-Bridge.

Getting ready

Following are the ingredients required for this recipe:

  • An Arduino board connected to a computer via USB
  • An Arduino-compatible motor shield; there is an official Arduino motor shield and a few other options from different companies such as Sparkfun, Pololu, or Adafruit
  • A DC motor

How to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required