Introduction: How to Make a Servo Leg

About: I like making things in my free time

This instructable will show you how to create a simple servo leg that can be controlled by buttons on an arduino or via serial.
Here is a video of the leg in action    http://www.youtube.com/watch?v=Q8i1nrPIJvo

Leg Materials:
Popsicle sticks-make sure that all of them are flat and not curved, like in the picture
Paper clip
4 3mm screws
Servo motor
weights

Leg tools:
Hot glue gun
wire strippers
needle nose pliers
Drill
3/32 inch drill bit
1/8 inch drill but
Sharpie

Electronics Materials:
Arduino
2 pushbuttons
2 10k ohm resistors
Breadboard
Jumper wires
USB cable to connect arduino and comuputer

Electronics Tools:
Computer
Arduino Environment

Step 1: Making the Parts of the Leg

In this step, I will show you how to create the parts of the leg.

Materials:
Popsicle sticks
Popsicle sticks
Popsicle sticks

Tools:
Hot Glue gun (and glue)

First, place a dot of glue a bit smaller than a pea on the end of a popsicle stick. Then put another popsicle stick on top of the glue making a double length popsicle stick with about 1/2 inch overlap. On the opposite face and same end of the popsicle stick, place another drop of glue and another popsicle stick. The end result should look like a narrow tuning fork. In between the open end of the "tuning fork" squeeze more glue on and then another popsicle stick. You should now have a triple length popsicle stick in the pattern of overlap "121". You need to make one more of these for a total of two.

Next, we need to make the base and the top of out leg, which are the same for ease of creation. First, place a dot of glue on one popsicle stick just a little offcenter. place another popsicle stick perpendicular to this one, creating a "T". At the other end of the "T" glue another popsicle stick offcenter in the same direction forming an "I". Place a popsicle stick sideways on the side of this closest to the center to cat ad a spacer. Then  place two dots of glue in front of the spacer and put another popsicle stick across the span, squeezing towards the spacer. Take the spacer out (this may take some force) and put another glue-free one in.
Now, place a thin line of glue on one of the spanning popsicle sticks. Place another sideways popsicle stick on top of this, squeezing towards the spacer. Place another popsicle stick just like this on the other side, still squeezing towards the spacer. At this time, remove the spacer (some more force) and nut a new one in.
Now, place another thin line of glue on the outside on one of the spanning sticks. Put another popsicle stick on top of it, angled towards one of the sideways sticks. Where the two sticks touch at the top, place another thin line of glue. Do this for the other side.
You also need to make one more of these for a total of two.

Step 2: Assembling the Leg

This step is about how to assemble the leg

Materials:
Leg parts (4)
4-3mm screws

Tools:
Drill
3/32 inch drill bit
1/8 inch drill bit
sharpie
Tape Measure

First, take the bases. On each end, measure from the inside and mark on the diagonal part 1/2 inch in. Do this for both sides on both bases. Drill a hole through these marks all the way through the base. First drill with the 3/32 bit, then go through with the 1/8 inch bit. this is because popsicle sticks are very prone to splitting and you need to be careful.
Next, mark a spot on each of the supports about 1/8 inch to 1/4 of an inch in. First, drill a 3/32 inch hole, then a 1/8 inch hole. Be EXTREMELY careful when drilling these holes as these are on the ends and splitting is even more common here! Drill one hole on each end of the supports this way.
To assemble this, line up the holes in one of the supports to one of the holes in the base. Place a screw through these (3mm should slide through fairly easily). Repeat this for each end and base. The end result should be a rectangle with flexible corners.
Finally, on one support, drill a 3/32 inch hole then a 1/8 inch hole about 1/2 inch up from the spot where the two sticks join into one. this is for the paperclip to go through.
Once the whole thing is standing, weigh it down with some sort of weights so it dosen't topple when moved.

Step 3: Attaching the Servo

In this step, I will show you how to attach the servo to the leg.

Materials:
Assembled leg
Servo Motor
Tape
Paper Clip

Tools:
Needle Nose Pliers
Wire Strippers

First, take the paper clip and straighten it. If it has a plastic coating, use the wire strippers to take about an inch of it off on one end.
Now, hold the the very end of the paperclip with the very end of the pliers and bend it at a sharp 90 degree angle.
Hold the paperclip at the very end of the pliers and on the inside of the first bend. Make another 90 degree bend in the opposite direction as the first. The result should look like a very small step in a staircase.
on the opposite end of the paperclip, hold the paperclip with the pliers about a half an inch in and make another 90 degree bend. About a fourth of an inch in on the same side, make a 45 degree bend.
about halfway down the paperclip, make another "step" with the pliers that is about an inch high. this will account for the fact that the servo position is offset from the support.

Place the "step" end into the servo so that the vertical part of the "step" is in the horn of the servo, and the first horizontal part is in the back.
Take the 90-45 degree end of the paperclip and insert the part just after the 90 degree bend into the hole. The 45 degree bend should lock it in place.

Now, take the servo and place it on top of the leg so that the paperclip and leg can freely move with the servo. Once you have found a good position, tape it in place.

Step 4: Mounting and Wiring the Breadboard

this step is about how to attach the components to and wire the breadboard.

Materials:
Breadboard
2 pushbutton switches
2-10k ohm resistors
Jumper wires
Arduino

Tools:
None :)

First, place the two pushbuttons on the breadboard
Take the resistors and on one end, place it in a column with the switch, and the other end on the inside rail of the breadboard.
use a jumper wire co connect the other side of the pushbutton to toe outside rail of the breadboard.
In the column with the pushbutton and resistor, place another jumper wire and connect it to pin 2 or 3 on the arduino. Pin 2 is for the left switch and pin 3 is for the right switch.

Connect the inside rail of the breadboard to the GND pin and the outside rail of the breadboard to the 5V pin on the arduino.

Connect the black wire of the servo to the inside rail using jumper wires, the red wire to the outside rail using a jumper wire, and the yellow wire of the servo to pin 8 on the arduino.
Now, all you have to do is load the code onto the arduino.

Step 5: THE CODE

This step is about how to get the leg working

Materials:
Leg & Electronics

Tools:
USB cable to connect arduino and computer
Computer
Arduino environment

Copy and paste the code into the arduino processing environment. Then load it on to your computer, and watch it work.
Press the left button to move the leg down, and press the right button to move the leg up.
If you open the serial port on your computer with the arduino connected, you can send it "u" to move the leg up or "d" to move it down.
Also, the state of the leg will be printed in the serial monitor once it is done moving

you may have to tweak some of the angles that the servo moves to to get it to go where you want it, but you should be good.

Here is the code:


#include <Servo.h>  //include the servo library
Servo myservo;
int pos = 0;   

int input = 0;
int switchState2 = 0;  //set the switches to be off initally
int switchState3 = 0;

void setup()
{
  myservo.attach(8);   //attach the servo to pin 8
 pinMode(2, INPUT);  //set the switches as inputs
pinMode(3, INPUT);
Serial.begin(9600);   // start serial communications
}


void loop(){
  input = Serial.read();
  switchState2 = digitalRead(2);  //read the switches for inputs
  switchState3 = digitalRead(3);          // the following tells the arduino
                                         //what to do if an input is given
   if (input == 'u' ) {                     //if the input is "u"
   for(pos = 30; pos < 145; pos += 1)  {    //prep to move from 30 degreed to 145 degrees             
    myservo.write(pos);                //actuall move the servo
    delay(25);}                         //do it at 1 degree every 25 milliseconds
    Serial.println("Leg is up");}       //print that the leg us up
  if (input == 'd'){
      for(pos = 145; pos>=30; pos-=1){                               
    myservo.write(pos);           
    delay(25);}
      Serial.println("Leg is down");}

  if (switchState3 == LOW){}               //if a switch is low, do nothing
  else {for(pos = 30; pos<145; pos+=1) { // if pressed, prep to move from 30 to 145           
    myservo.write(pos);                   //actually move the servo
    delay(25); }                          // do it 1 degree every 25 milliseconds
  Serial.println("Leg is up");}           // print that the leg is up
  if (switchState2 == LOW) {}
  else {for(pos = 145; pos>=30; pos-=1){                               
    myservo.write(pos);           
    delay(25);}
  Serial.println("Leg is down");}
}

UP! Contest

Participated in the
UP! Contest