Arduino Servo Projects
Robert J Davis II
Arduino Servo Projects Copyright 2015 by Robert J Davis II All rights reserved This is essentially a continuation of my earlier book Arduino Robotics Projects. These are some more advanced robotics projects and they will use a lot of servos. Some readers have complained that the projects in the earlier book required specific toys in order to work. That was not the intention. Instead the book was meant to teach the basics for robotics and then to show some simple examples showing how to apply what you have learned. This book will repeat some of what was covered in that book in case you did not read it first.
Disclaimer: Once again the safe construction and operation of these devices is solely up to the reader. The reader must take all safety precautions and accept all responsibility for the safe operation of these devices. There are no guarantees implied with the circuit designs and software programs that are found within this book. Disclaimer 2: No two servos work exactly the same. No two robots are built exactly the same. The software in this book may not work with your robot without some adjustment to the servo positions in software and hardware.
This is normal and should be expected. The most important thing is for you to have lots of fun! Try out some projects in this book and see what you like. Make your own hardware and software improvements. I am sure you can come up with some better designs! A common acronym that is used when referring to robots is DOF or Degrees of Freedom. It generally refers to the amount of servo motors that are used to give the robot mobility.
Table of Contents 1.
Working with Servos How Servos Work Typical Servos Setting up the Servos Working With More than 12 Servos 2. The Servo Building Blocks The Various Parts Parts Sources Making a better Chest 3. Servo Controller Shield How to Build Your Own Battery Arrangements 4. IR Remote Control Setup Reading Your Remote codes 5. Bluetooth Setup 6. Walking Humanoid Robot 9 DOF Making your own Feet 7.
Walking Humanoid Robot 13 DOF Adding Knees and Hands 8. Walking Humanoid Robot 17 DOF Improved Hips and Hands 9. Walking Dog Robot 14 DOF 10. Walking Dinosaur Robot 17 DOF Adding the Tail Bibliography
Chapter 1 Working with Servos Servos are motors that have a built in motor controller and a feedback loop. Basically a variable resistor or other device monitors the motors position. This information is then fed back to the built in motor controller.
The motor controller takes commands that are usually in the form of a pulse width. Then the controller matches up the motor position with what position the pulse width told it to move the motor to.
Servos typically come in several sizes, as can be seen in the above picture. There are the larger servos on the left, normal standard sized servos in the middle and a micro sized servo on the right. The middle size of servo is the one we will use for most of these projects. You might note that most micro servos have only one mounting hole at each end instead of two mounting holes.
In the case of pulse width modulation commands, usually a pulse width of one millisecond tells the servo to move to zero degrees. A pulse width of 1.5 milliseconds tells the servo to move to 90 degrees. A pulse width of two milliseconds tells the servo to move almost completely open or 180 degrees. The servo home position is usually at 90 degrees or in the middle of its range. For some servos the position and pulse width may vary. You might find that for some servos a .5 millisecond pulse results in zero degrees of rotation and a 2.5 millisecond pulse results in 180 degrees of rotation.
In any case there is also a 20 millisecond delay between each of the control pulses. Here is a chart showing the pulse width and the corresponding position of the servo motor.
Some of the advantages of servo motors include that the power source does not have to be switched on or off or otherwise controlled. The power to the servo motor can always be left on. This time a PWM output pin of the Arduino can directly control the servo, no driver circuit or transistor is needed, because there is a driver inside of the servo. Servos make great proportional valve controllers because you can vary a valve from off to full on.
For instance, if you want to water your plants automatically and you want the rate of water flow to be adjusted according to the humidity, it can be done with a servo. Here is a picture of the Arduino servo motor test setup. That is a micro servo being used for the servo demo.
Here is a sketch to demonstrate the operation of a servo motor. For this experiment the center or output of a variable resistor is connected to A0. /********************************* // Servo motor demonstration program // By Bob Davis // July 10, 2013 // Servo Connected to Gnd, Vin, and D9 // Variable resistor on AO, high end=5V and low end=Gnd /**********************************/ #include Servo demoservo; // The variable resistor is on A0 int vrpin = 0; int pos; void setup() { // The servo is on pin 9 demoservo.attach(9); } void loop() { // Read the variable resistor, 1024/5=205 degrees rotation // Values over 180 are ignored pos = analogRead(vrpin)/5; // send the position to the servo demoservo.write(pos); delay(25); } For the projects in this book you will also need about 9 to18 servo motors. /********************************* // Servo motor demonstration program // By Bob Davis // July 10, 2013 // Servo Connected to Gnd, Vin, and D9 // Variable resistor on AO, high end=5V and low end=Gnd /**********************************/ #include Servo demoservo; // The variable resistor is on A0 int vrpin = 0; int pos; void setup() { // The servo is on pin 9 demoservo.attach(9); } void loop() { // Read the variable resistor, 1024/5=205 degrees rotation // Values over 180 are ignored pos = analogRead(vrpin)/5; // send the position to the servo demoservo.write(pos); delay(25); } For the projects in this book you will also need about 9 to18 servo motors.
Some of my servos are seen in the next picture. Here are a few of the needed servos, they are mostly MG995's and MG996s. These are not the best servos as far as smooth movements, accurate returns, etc. However these servos will work for most of the projects found in this book.
These are some specs for some popular servos. Basically you want a normal sized servo with over 100 oz-inches of torque that does not cost a fortune.
Servos with 150 oz-inches of torque would be even better.
Make | Model | Size | Torque 5V | Price |
Futaba | S148 | Standard | 33 oz-in | $15 |
Futaba | S3001 | Standard | 33 oz-in | $25 |
Futaba | S3003 | Standard | 44 oz-in | $12 |
Futaba | S3004 | Standard | 44 oz-in | $13 |
Futaba | S3010 | Standard | 72 oz-in | $25 |
Futaba | S3305 | Standard |