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 ...

Get Arduino Sketches: Tools and Techniques for Programming Wizardry now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.