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

CHAPTER14

Servo

This chapter discusses the following functions of servo motors:

  • attach()
  • attached()
  • write()
  • writeMicroseconds()
  • read()
  • detach()

The hardware needed to run the examples in this chapter includes:

  • Arduino Uno
  • USB Cable
  • Breadboard
  • LM35
  • HYX-S0009 or equivalent servo motor

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

Introduction to Servo Motors

Most motors are simple devices that turn on their axle when current is supplied. When a motor turns, the user generally has no idea about the angle or speed; to get this information, sensors are required. Servo motors differ by knowing exactly the angle that they are at and adjusting their position as required. Most servo motors cannot turn 360 degrees; instead, they are often limited to a range. Most servo motors have 180 degrees of rotation, as shown in Figure 14-1.

image

Figure 14-1: Servo motor movement

To know the exact position, servo motors can use a wide variety of techniques. Most use a potentiometer, using electrical resistance to understand how far the arm has turned, while more advanced systems use a coded optical wheel to get precise information.

Servo motors were originally designed in the dark times of war. They were used in radar and anti-aircraft artillery during ...

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