Project tutorial
Build A Tripod Using Arduino and Servo Motors

Build A Tripod Using Arduino and Servo Motors © GPL3+

In this post, I will show you how to build a three legged robot (a tripod) using Arduino and servo motors.

  • 3,276 views
  • 0 comments
  • 7 respects

Components and supplies

Ard nano
Arduino Nano R3
×1
Servos (Tower Pro MG996R)
×9
Lithium Polymer
×1
PCA9685 16 Channel 12 Bit Servo motor driver
×1

About this project

While I was thinking about the next project, lots of things came to my mind. But this time, I thought of doing something new. Going through the scraps, I found 11 servo motors that I purchased for a project 4 years ago. Let's see, Arduino, servo motor, servo motor driver, regulator. Hmm... Why not something that could walk? So, I decided to get rid of all the wheels and make a 3 legged walking robot. In this post, I will show you how to build a three legged robot (a tripod) using Arduino and servo motors.

Materials Needed

Arduino Nano

Or any Arduino board which will be the controlling center of our project

Voltage Regulator Module

For providing controlled and stable DC source for the working of servo motors as well as internal chips.

PCA9685 16 Channel 12 Bit PWM I2C-bus controlled Servo motor Driver

Now we need some thing to drive all the 9 servos. I am using Adafruits PCA9685 16 Channel PWM Module. The PCA9685 is a 16 Channel 12 Bit PWM I2C-bus controlled Servo motor driver. The Driver can very easily connected to your Arduino, Raspberry Pi and easily programmed to control single or multiple servo motors and make your own RC plane, car, ship, quadrapod, hexapod or anything you want.

To know how to control a servo motor using this driver, watch the video below.

Servo Motor

These are servo motors. They are widely used in the field of robotics due to its precise control of position, velocity and acceleration.

These servo motors can be combined together to provide multiples degrees of freedom. In this project, we are using 3 servo motors in each leg which gives us 3 degrees of freedom. So we need a total of 9 servo motors.

The Regulator

Arduino and servo motor that I am using needs a voltage between 5v and 6v. Since I am using a lithium polymer battery of 11v, I will have to use regulator. The regulator I am using is LM 2596S 20083 adjustable voltage regulator. It is really easy to setup 1 yourself but If you don't know how to use, watch the below video tutorial in which I explained the usage of this regulator.

In the current project, I set the operating voltage to 5.5 V. Servo motors take too much current from the power source. If we are using a single regulator, it may overheat when multiple servo motors are running. So it is always a better idea to use multiple regulators in parallel in these cases.

The Body Parts and Designs

The material for the leg is acrylic sheet and the body is made of foam board. I designed these body parts in coral draw and got it laser cut from a nearby workshop. I will upload the layout here. Feel free to use it.

These are the different parts. For the base of the tripod, you can use any lightweight material. Here I had some foam board so I used it. You have to cut 3 holes to mount the base servo motors. Clean the edges otherwise it be difficult for the servo motor to fit in.

Let's Start

Logon to www.greenterminal.in for more fun projects and tutorials. It would be better if you can watch the video just below for clearly understanding what is going on. Watch this:

Start by fixing all the servo motors in the body parts as shown in the video. Just fix it with some nuts and bolts and tighten all the connection so that it wont fall off or shake while the tripod is moving.

Use some strong glue and join 2 servo motors as shown in the video. Combining two servo motors like this will give us 2 degrees of freedom. Connect the elbow part with the other joints. Connecting the elbow part with these 2 servo motor will give each arm of the tripod, a total of 3 degrees of freedom, which is more than enough to make it walk the way we want.

Now fix all the legs to the foam base as shown in the video. Fix the two regulators somewhere it wont be disturbed. I fixed these at the bottom of the foam board base. Attach it with screws and use hot glue gun so that all the connections will be secure. Fix the servo driver module in another piece of foam board and secure it with screws. Use double sided tape to fix the battery and foam board piece with the base of our tripod. At last, fix our Arduino on the top foam board near the servo driver board.

All the connections in this project are very easy. Just connect the battery to our regulator input and servo driver and Arduino to the regulator output. I will share the schematics and circuit diagrams soon.

This is our tripod after all the connections.

It is a little bit messy. So lets clean it up. Use some zip-ties to organize all the wires.

Make sure that Arduino and servo driver are near to each other. Otherwise, the connections will be little bit hard.

Now its time to program our tripod. Connect the Arduino to our PC. Just go to device manager and check the device port. Now open Arduino IDE. Below is a sample sketch just to check all the motors functionality.

#include <Wire.h> 
#include <Adafruit_PWMServoDriver.h>  
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();  
#define MIN_PULSE_WIDTH       650 
#define MAX_PULSE_WIDTH       2350 
#define DEFAULT_PULSE_WIDTH   1500 
#define FREQUENCY             50  
uint8_t servonum = 0;  
void setup()
  {
   Serial.begin(9600);
   Serial.println("16 channel Servo test!");
   pwm.begin();
   pwm.setPWMFreq(FREQUENCY);
   pwm.setPWM(0, 0, pulseWidth(100));
   delay(500);
   pwm.setPWM(4, 0, pulseWidth(60));
   delay(500);
   pwm.setPWM(12, 0, pulseWidth(60));
   delay(500);
   pwm.setPWM(1, 0, pulseWidth(10));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(170));
   delay(500);
   pwm.setPWM(13, 0, pulseWidth(170));
   delay(500);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(500);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(500);
   pwm.setPWM(14, 0, pulseWidth(110));
   delay(500);
  } 
int pulseWidth(int angle)
 {
   int pulse_wide, analog_value;
   pulse_wide   = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
   analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
   Serial.println(analog_value);
   return analog_value;
 }  
void loop()
 {
   pwm.setPWM(0, 0, pulseWidth(150));
   pwm.setPWM(13, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(14, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(1, 0, pulseWidth(0));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   delay(50);
   pwm.setPWM(14, 0, pulseWidth(110));
   delay(1000);
   pwm.setPWM(0, 0, pulseWidth(50));
   delay(1000);
   pwm.setPWM(4, 0, pulseWidth(120));
   delay(1000);
   pwm.setPWM(1, 0, pulseWidth(20));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(160));
   delay(500);
   pwm.setPWM(0, 0, pulseWidth(100));
   delay(500);
   pwm.setPWM(4,0, pulseWidth(60));
   delay(500);
 }  

This is just a simple code just to move the servo motors. Paste the code to Arduino IDE go to boards, select correct COM port and board and upload the sketch.

If the code is uploaded successfully, with in 15 seconds, all the servo motor will start to move. Congrats, you have done it!

Now I am working on writing the codes for the tripod to walk, run, duck and some other complex movements and integrate various sensors into this tripod to fully automate it. Once I complete that, I will upload it in my blog.

Logon to www.greenterminal.in for more fun projects and tutorials. Stay tuned for more.

Code

Sample SketchArduino
#include <Wire.h> 
#include <Adafruit_PWMServoDriver.h>  
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();  
#define MIN_PULSE_WIDTH       650 
#define MAX_PULSE_WIDTH       2350 
#define DEFAULT_PULSE_WIDTH   1500 
#define FREQUENCY             50  
uint8_t servonum = 0;  
void setup()
  {
   Serial.begin(9600);
   Serial.println("16 channel Servo test!");
   pwm.begin();
   pwm.setPWMFreq(FREQUENCY);
   pwm.setPWM(0, 0, pulseWidth(100));
   delay(500);
   pwm.setPWM(4, 0, pulseWidth(60));
   delay(500);
   pwm.setPWM(12, 0, pulseWidth(60));
   delay(500);
   pwm.setPWM(1, 0, pulseWidth(10));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(170));
   delay(500);
   pwm.setPWM(13, 0, pulseWidth(170));
   delay(500);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(500);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(500);
   pwm.setPWM(14, 0, pulseWidth(110));
   delay(500);
  } 
int pulseWidth(int angle)
 {
   int pulse_wide, analog_value;
   pulse_wide   = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
   analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096);
   Serial.println(analog_value);
   return analog_value;
 }  
void loop()
 {
   pwm.setPWM(0, 0, pulseWidth(150));
   delay(1000);
   pwm.setPWM(4, 0, pulseWidth(10));
   delay(1000);
   pwm.setPWM(13, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(14, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(1, 0, pulseWidth(0));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(180));
   delay(500);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(180));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(45));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(180));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(45));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(180));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(45));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(180));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(45));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(120));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(85));
   delay(50);
   pwm.setPWM(2, 0, pulseWidth(180));
   delay(50);
   pwm.setPWM(6,0 , pulseWidth(45));
   delay(50);
   pwm.setPWM(14, 0, pulseWidth(110));
   delay(1000);
   pwm.setPWM(0, 0, pulseWidth(50));
   delay(1000);
   pwm.setPWM(4, 0, pulseWidth(120));
   delay(1000);
   pwm.setPWM(1, 0, pulseWidth(20));
   delay(500);
   pwm.setPWM(5, 0, pulseWidth(160));
   delay(500);
   pwm.setPWM(0, 0, pulseWidth(100));
   delay(500);
   pwm.setPWM(4,0, pulseWidth(60));
   delay(500);
 }  

Comments

Similar projects you might like

Littlearm 2C: Build a 3D Printed Arduino Robot Arm

Project tutorial by Slant Concepts

  • 4,403 views
  • 1 comment
  • 32 respects

OttoDIY Build Your Own Robot in One Hour!

Project tutorial by Camilo Parra Palacio

  • 106,031 views
  • 129 comments
  • 305 respects

Servo

by Grant

  • 9,370 views
  • 13 comments
  • 23 respects

Super Easy to Build 1Sheeld 2 Wheel Drive Robot

Project tutorial by Garry Gerwer and Ahmed Hamdy

  • 16,686 views
  • 3 comments
  • 32 respects

Autobot Using Lego NXT Motors and Sensor

Project tutorial by Mark Tashiro

  • 14,206 views
  • 5 comments
  • 25 respects

How to Build Sauron The Lord of the Robots

Project tutorial by Mahmoud Ahmed

  • 6,159 views
  • 5 comments
  • 26 respects
Add projectSign up / Login