Sunday 22 September 2013

WALKING ROBOT USING ARDUINO

Building a simple walking robot is really easy. Don't let the number of steps fool you into believing otherwise. This robot is basically made with a handful of household items and some simple electronics that you can easily pick up at Radioshack.
In fact, this robot is entirely zip tied together, which makes building it and modding it extremely easy.
If at any point you are unhappy with how its built, cut the zip ties away and zip tie it together differently.

The "brains" of this robot are also easily modifiable since it is based on an Arduino development board. Programming it and changing the code is extremely straight-forward. Even people with no programming experience can usually get up to speed pretty quickly and start coding their own robotic routines.

For me, this robot was mainly an experiment to see what would happen if I built a full-on robot that was like one of the many Simple Bots that I have built. It was interesting to see how much more robust one of these creatures become when you give it some computer logic.

You will need:

(x4) Rubber spatulas
(x2) 6" turnbuckles
(x1) 2" x 48" aluminum ruler
(x1) Ballpoint pen
(x1) 4-40 x 1/4" nut and bolt
(x1) Arduino Uno REV 3 (Radioshack #276-128)
(x2) Parallax 4-6VDC Standard Servo (Radioshack #273-441)
(x2) 3x1 male header pins (strips of 40 available in Radioshack #277-077)
(x1) Parallax Ping Sensor (Radioshack #276-136)
(x1) Heavy-Duty 9V Snap Connectors (Radioshack #270-324)
(x1) 9-Volt Battery Holder (Radioshack #270-326)
(x1) Size M Coaxial DC Power Plug (Radioshack #274-1569)
(x1) Multipurpose PC Board with 417 Holes (Radioshack #276-150)
(x1) 90-Ft. UL-Recognized Hookup Wire (Radioshack #278-1221)
(x1) Enercell® Alkaline 9 Volt Battery (Radioshack #25-853)
(x1) 5-1/2" Zip Ties (Radioshack #278-1631)

Get a 2" wide aluminum ruler.

Cut a 10" section off one end using a hacksaw.

Cp the cut section of ruler in a bench vise such that 5" are sticking out.

Bend the aluminum slightly (to about 30 degrees) using a rubber mallet or hammer.

If you don't have a bench vise, hang the ruler halfway off the edge of your workbench, place a block of wood atop the ruler and clamp it firmly in place. You have now made an impromptu bending rig.

Simply hammer down on the ruler until it bends down over the edge of the workbench.
Take your turnbuckles and remove all of the eyelets.

Set them aside for some other project.





















Widen the second hole from center with a 1/8" drill bit on each arm of the servo horn.

Repeat this for the second servo.

Place the turnbuckle on edge. Measure 3" across one of the turnbuckles. Make a mark at this point. Repeat on the second turnbuckle.

Place the servo horn at the 3" center point on the turnbuckle.

Position the horn such that it is making a "V" perpendicular to the length of the turnbuckle. This should, by default, position two more "V" shapes pointing to each side of the turnbuckle. Make marks in the valley of each of these "V" shapes.

Finally, drill these two marks with a 1/8" drill bit.

Repeat on the second turnbuckle.

One inch from the edge of each of the far sides of the ruler, make a centered mark.

make the robot design as per the pictures

and make the connections,

PROGRAM :

/*
Simple Walker Robot
by Randy Sarafan

This code is for controlling a simple quadruped robot and having it respond to obstacles that approach.

For more information visit the project page:
http://www.instructables.com/id/Simple-Walker-Robot/

This code is based on both the Arduino Sweep example by BARRAGAN 
and the Arduino Ping example by Tome Igoe
*/

#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 

Servo myservo1; // create a second servo object to control a servo 

int pos = 80;   // variable to store the servo position for rear legs
                //changing this value changes the default position of the rear legs
int pos1 = 70;  // variable to store the servo position for front legs 
                //changing this value changes the default position of the front legs 

//determines the rate at which the legs move
int rate = 1000;

// this constant won't change.  It's the pin number
// of the sensor's output:
const int pingPin = 7;

void setup() 

  myservo.attach(9);      // attaches the servo on pin 9 to the servo object 
  myservo1.attach(10);    // attaches the servo on pin 10 to the servo object 

  myservo.write(pos);     // tell servo to go to position in variable 'pos' - sets center axis
  myservo1.write(pos1);   // tell servo to go to position in variable 'pos' - sets center axis
  delay(5000);



void loop() {
  
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);  

  //if something is closer than a foot, back away
  if(inches <= 12){
    backward();
  }
  
  //if nothing is closer than a foot, go forwards
  if(inches > 12){
    forward();
  }




//function for going forwards
void forward(){
  myservo.write(pos + 20);                // tell servo to go to position in variable 'pos' 
  myservo1.write(pos1 - 20);              // tell servo to go to position in variable 'pos' 
  
  delay(rate);
  
  myservo.write(pos - 20);                // tell servo to go to position in variable 'pos' 
  myservo1.write(pos1 + 20);              // tell servo to go to position in variable 'pos' 
  delay(rate);
}

//function for backing away
void backward(){
  myservo.write(pos + 25);                // tell servo to go to position in variable 'pos' 
  myservo1.write(pos1 + 50);              // tell servo to go to position in variable 'pos' 
  
  delay(rate);
  
  myservo.write(pos - 25);                // tell servo to go to position in variable 'pos' 
  myservo1.write(pos1 - 30);              // tell servo to go to position in variable 'pos' 
  delay(rate);
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}



DONT WORRY ABOUT THE CIRCUIT ...IT IS SHOWN IN PICTURES...
 BE CAREFULL WHILE PROGRAMMING....





1 comment: