O'Reilly logo

Arduino Sketches: Tools and Techniques for Programming Wizardry by James A. Langbridge

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

CHAPTER15

Stepper

This chapter discusses the following functions of the Stepper library:

  • Stepper()
  • setSpeed()
  • step()

The hardware needed to use these functions includes:

  • Arduino Uno
  • 1 x L293D
  • 1 x 5-V bipolar stepper motor
  • Breadboard
  • Cables

You can find the code downloads for this chapter at http://www.wiley.com/go/arduinosketches on the Download Code tab. The code is in the Chapter 15 download and the filename is Chapter15.ino.

Introducing Motors

Electric motors generally work by creating electromagnetic fields from coils, forcing magnets on an axle to move, therefore driving the axle. By generating electromagnetic fields, a motor turns continuously until current is removed.

Servo motors (presented in Chapter 14) function a little differently, but even if their usage is different, a servo motor is still controlled by an ordinary electric motor managed by a small microcontroller to ensure the servo motor can move to a precise position.

Stepper motors are different. They have several coils inside, and the internal axle is “toothed.” When applying current to one of the coils, the closest “tooth” is attracted to the coil, and the axle moves by a few degrees. Current is then removed from the coil and sent through another coil, again attracting a tooth and moving the axle by a few degrees. By repeating this operation, a stepper motor can be controlled to turn continuously in either direction, but this is not normally a stepper motor's main function. Stepper motors can have precise ...

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