Arduino Controlled Spider Robot Project
by robotistan in Circuits > Arduino
133 Views, 0 Favorites, 0 Comments
Arduino Controlled Spider Robot Project
Hello fellas! In this instructable we will learn how to make a Spider Robot with you.
Spider Robot is a great robot kit for hobbyists and robotics enthusiasts who want to start building robots. We will proceed by explaining the installation stages with visuals and we will reveal a robot that we can control with an IR control.
In fact, with the changes you can make, you will be able to control the robot with a TV remote or other methods. Then let's not waste much time, let's get to know the project!
Supplies
To do this project, you need the Robotistan made Spider Robot Kit. The Robot Kit designed for quick start, so kit comes with all parts of the project. The kit includes all the necessary parts and components.
Review the kit on Amazon : Arduino Spider Robot Kit
Also, you can find the e-book which provides all the steps about this project. You can download the manual's pdf version from above.
Downloads
Adjusting Servo Motors Positions
Before starting the assembly, we need to manually adjust the angle adjustment of the servo motors. Otherwise, your robot will not work properly.
Attach the Servo Arm to the servo, and then slowly turn the servo arm clockwise until the arm stops. It's okay if the servo arm doesn't stop at the same angle shown in the picture above. The important thing is that we find the end point of the servo. Remove the servo arm from the servo and reposition it so that it is perpendicular to the servo body.
Slowly turn the servo arm counterclockwise until it is parallel with the servo body as shown. This is the center position of the servo and it is important to center the 8 servos in the set before starting the assembly of the robot. After the servo arm is parallel to the servo body, remove the servo arm and set it aside for later assembly.
If your servo motors are 360 degree analog servos, you cannot do manual cabling. That's why you can calibrate your servo motors thanks to the code I shared with you. As in the circuit diagram at the above (3), turn your servo motors into 1.2.3.4.5.6.7.8. Install the code at the bottom to your arduino by attaching it to the pins. If you do not do this, your robot will not work stably.
Servo Calibration Code :
#include <Servo.h> // include servo library// Define 8 ServosServo myServo1; // Front Left Pivot ServoServo myServo2; // Front Left Lift ServoServo myServo3; // Back Left Pivot ServoServo myServo4; // Back Left Lift ServoServo myServo5; // Back Right Pivot ServoServo myServo6; // Back Right Lift ServoServo myServo7; // Front Right Pivot ServoServo myServo8; // Front Right Lift Servovoid setup() { // put your setup code here, to run once: myServo1.attach(1); myServo2.attach(2); myServo3.attach(3); myServo4.attach(4); myServo5.attach(5); myServo6.attach(6); myServo7.attach(7); myServo8.attach(8); myServo1.write(90); myServo2.write(90); myServo3.write(90); myServo4.write(90); myServo5.write(90); myServo6.write(90); myServo7.write(90); myServo8.write(90);}void loop() { // put your main code here, to run repeatedly:}
If you have done with the servo adjustments, let's begin to Leg Assembly stages..
Leg Assembly Stages
You have to make the leg connections by following the step-by-step visuals. You can make the connections by following the step names from the schematic. Repeat steps 1 through 10 exactly 4 times and build 4 legs :
Step 1 : Place a servo single arm on the pedestal pivot plate and screw the servo mounting screw into the servo single arm from the rear of the leg up pivot plate.
Step 2 : Attach a servo single arm to the standing servo arm and attach a servo mounting screw to the servo. Screw on the servo single arm from the back of the leg servo arm.
Step 3 : Attach a leg parallel joint to the leg piece using an M3x10mm screw and an M3 fiber nut.
Step 4 : Attach the leg piece to the leg servo arm using an M3X10mm screw and an M3 fiber nut.
Step 5 : Insert a Servo into the Servo Holder.
Step 6 : Insert the top end of the Servo into the Pedestal Servo slot.
Step 7 : Attach the servo holder to the leg Servo socket using two M3 x 12mm screws and two M3 fiber nuts.
Step 8 : Attach a leg parallel plate to the other end of the leg using the M3X10MM screw and M3 fiber nut.
Step 9 : With the servo rotated to the center position and the leg parallel joint positioned horizontally, attach the leg servo arm to the servo using the servo arm screw supplied with the servo
Step 10 : Attach the Leg Assembly from the previous steps to the Leg Bottom Pivot Plate using two M3 x 10mm Screws and two M3 Nuts.
Leg Assembly was a little difficult, but believe me, if these stages are over, the rest is coming. If you have completed these steps, let's move on to the Body Assembly part..
Body Assembly
In this stage, you should be careful with the numbers. Schematics is explained according to the part numbers, so that you should read the lists that we created, before the asssembly ;
Part List of Schema 1 & 2:
- 1- Body Upper Plate
- 2- M3x10MM Screw
- 3 - Servo Motor
- 4 - M3 Nut
- 5 - M3 Fiber Nut
- 7 - M3x12MM Screw
- 8 - Spacer
- 10 - Servo Holder
Step 11 : Attach the four stem spacers to the stem bottom plate using four M3x10mm screws and four M3 flat nuts.
Step 12 : Place four servos on the top of the chassis top plate.
Step 13 : Attach a servo holder to the top of each servo.
Step 14 : Attach each servo holder to the chassis top plate using M3x12mm screws and M3 fibers nuts.
Part List of Schema 3, 4 & 5:
- 1 - Servo Screw
- 2 - M3x10MM Bolt
- 3 - M3 Nut
- 4 - M3 Fiber Nut
Step 15 : Attach each leg piece to the stem bottom plate using an M3x10mm screw and M3 fiber nut. Do not over tighten the screws, it may cause malfunction of the servos.
Step 16 : Attach the body bottom plate to the body top plate using four pieces, using M3x10mm screws and M3 nuts.
Step 17 : Rotate each leg so that it is oriented at a 45 degree angle as shown. Install the leg upper pivot plate. Mount to each pivot servo and leg using two M3x10mm screws and two M3 nuts.
Step 18 : Secure the servo single arm to the servo using a servo screw.
Finally, fix the battery holder to the lower part of the robot using the plexi risers.
Arduino Connections
Its time to make connections between Arduino and components.
Please follow the instructions :
- front-left-axis : Pin 2
- front-left-lift : Pin 3
- back-left-axis : Pin 4
- back-left-lift : Pin 5
- back-right-axis : Pin 6
- back-right-lift : Pin 7
- front-right-axis : Pin 8
- front-right-lift : Pin 9
- IR Module : Pin 12
Connect the servo motors in order starting from the 2nd digital pin to the 9th digital pin as seen in the circuit diagram. Connect the IR receiver module to the 12th pin as in the diagram.
Since the spider robot works with more than one servo motor, the power of the arduinon is insufficient, for this we need to make an external power input.
You need to energize the shild with a minimum 4.8v maximum 5v power supply. It is up to you what kind of energy you will give, whether with a lipo battery or a classic battery.
The important thing here is that it should not exceed 5 volts, otherwise your Arduino will be damaged. I have shared a few battery samples with you (second picture) as an example. If you are going to use a lipo battery type battery on the upper side, you must use the voltage reducing circuit on the side. Because voltages greater than 5 volts will damage your card.
As seen in the circuit diagram (third picture), it will be sufficient to set the output of the voltage reducing circuit to 5 volts and attach it to the shield.
Also, you can use classic AAA Batteries instead. To do that, you should plug 4 AAA battery into battery holder and then connect to the Arduino shield. (fourth Picture)
Uploading Arduino Codes & Conclusion
We have prepared a code for you so that you can move the spider robot without any problems at first. A few commands are ready in the code, but you can revise it yourself ;
#include <IRremote.h> // include IR Remote library#include <Servo.h> // include servo library//===== Globals ============================================================================// Define USRF pins and variables#define trigPin A3#define echoPin A2#define INCH 0#define CM 1// Define IR Remote Button Codes#define irUp 16736925#define irDown 16754775#define irRight 16761405#define irLeft 16720605#define irOK 16712445#define ir1 16738455#define ir2 16750695#define ir3 16756815#define ir4 16724175#define ir5 16718055#define ir6 16743045#define ir7 16716015#define ir8 16726215#define ir9 16734885#define ir0 16730805#define irStar 16728765#define irPound 0000005#define irRepeat 16732845// calibrationint da = -12, // Left Front Pivot db = 10, // Left Back Pivot dc = -18, // Right Back Pivot dd = 12; // Right Front Pivot// servo initial positions + calibrationint a90 = (90 + da), a120 = (120 + da), a150 = (150 + da), a180 = (180 + da);int b0 = (0 + db), b30 = (30 + db), b60 = (60 + db), b90 = (90 + db);int c90 = (90 + dc), c120 = (120 + dc), c150 = (150 + dc), c180 = (180 + dc);int d0 = (0 + dd), d30 = (30 + dd), d60 = (60 + dd), d90 = (90 + dd);// start points for servoint s11 = 90; // Front Left Pivot Servoint s12 = 90; // Front Left Lift Servoint s21 = 90; // Back Left Pivot Servoint s22 = 90; // Back Left Lift Servoint s31 = 90; // Back Right Pivot Servoint s32 = 90; // Back Right Lift Servoint s41 = 90; // Front Right Pivot Servoint s42 = 90; // Front Right Lift Servoint f = 0;int b = 0;int l = 0;int r = 0;int spd = 3; // Speed of walking motion, larger the number, the slower the speedint high = 0; // How high the robot is standing// Define 8 ServosServo myServo1; // Front Left Pivot ServoServo myServo2; // Front Left Lift ServoServo myServo3; // Back Left Pivot ServoServo myServo4; // Back Left Lift ServoServo myServo5; // Back Right Pivot ServoServo myServo6; // Back Right Lift ServoServo myServo7; // Front Right Pivot ServoServo myServo8; // Front Right Lift Servo// Set up IR Sensorint irReceiver = 12; // Use pin D12 for IR SensorIRrecv irrecv(irReceiver); // create a new instance of the IR Receiverdecode_results results;//==========================================================================================//===== Setup ==============================================================================void setup(){ // Attach servos to Arduino Pins myServo1.attach(2); myServo2.attach(3); myServo3.attach(4); myServo4.attach(5); myServo5.attach(6); myServo6.attach(7); myServo7.attach(8); myServo8.attach(9); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); irrecv.enableIRIn(); //start the receiver Serial.begin (9600);}//setup//==========================================================================================//== Loop ==================================================================================void loop(){ unsigned long value; unsigned long lastValue; center_servos(); // Center all servos high = 15; // Set hight to 15 spd = 3; // Set speed to 3 while (1 == 1) // Loop forever { if (irrecv.decode(&results)) // If we have received an IR signal { value = results.value; if (value == irRepeat) value = lastValue; switch (value) { case irUp: lastValue = irUp; forward(); break; case irDown: lastValue = irDown; back(); break; case irRight: lastValue = irRight; turn_right(); break; case irLeft: lastValue = irLeft; turn_left(); break; case irOK: lastValue = irOK; break; case ir1: lastValue = ir1; bow(); break; case ir2: lastValue = ir2; wave(); break; case ir3: lastValue = ir3; increase_speed(); break; case ir4: lastValue = ir4; break; case ir5: lastValue = ir5; break; case ir6: lastValue = ir6; decrease_speed(); break; case ir7: lastValue = ir7; break; case ir8: lastValue = ir8; dance(); break; case ir9: lastValue = ir9; break; case ir0: lastValue = ir0; center_servos(); break; case irStar: lastValue = irStar; trim_left(); break; case irPound: lastValue = irPound; trim_right(); break; default: break; } irrecv.resume(); //next value delay(50); // Pause for 50ms before executing next movement }// if irrecv.decode }//while}//loopvoid dance(){ center_servos(); delay(100); lean_left(); delay(300); lean_right(); delay(300); lean_left(); delay(300); lean_right(); delay(300); lean_left(); delay(300); lean_right(); delay(300); lean_left(); delay(300); lean_right(); delay(800); center_servos(); delay(300); bow(); center_servos();}//== Wave ==================================================================================void wave(){ /* myServo1 - Front Left Pivot Servo myServo2 - Front Left Lift Servo myServo3 - Back Left Pivot Servo myServo4 - Back Left Lift Servo myServo5 - Back Right Pivot Servo myServo6 - Back Right Lift Servo myServo7 - Front Right Pivot Servo myServo8 - Front Right Lift Servo */ center_servos(); myServo4.write(45); myServo6.write(45); delay(200); myServo8.write(0); delay(200); myServo7.write(180); delay(200); myServo7.write(30); delay(300); myServo7.write(180); delay(300); myServo7.write(30); delay(300); myServo7.write(s41); delay(300); myServo8.write(s42); center_servos();}//== Bow ===================================================================================void bow(){ center_servos(); delay(200); myServo2.write(15); myServo8.write(15); delay(700); myServo2.write(90); myServo8.write(90); delay(700);}//== Lean_Left =============================================================================void lean_left(){ myServo2.write(15); myServo4.write(15); myServo6.write(150); myServo8.write(150);}//== Lean_Right ============================================================================void lean_right(){ myServo2.write(150); myServo4.write(150); myServo6.write(15); myServo8.write(15);}//== Lean_Left =============================================================================void trim_left(){ da--; // Left Front Pivot db--; // Left Back Pivot dc--; // Right Back Pivot dd--; // Right Front Pivot}//== Lean_Right ============================================================================void trim_right(){ da++; // Left Front Pivot db++; // Left Back Pivot dc++; // Right Back Pivot dd++; // Right Front Pivot}//== Forward ===============================================================================void forward(){ // calculation of points // Left Front Pivot a90 = (90 + da), a120 = (120 + da), a150 = (150 + da), a180 = (180 + da); // Left Back Pivot b0 = (0 + db), b30 = (30 + db), b60 = (60 + db), b90 = (90 + db); // Right Back Pivot c90 = (90 + dc), c120 = (120 + dc), c150 = (150 + dc), c180 = (180 + dc); // Right Front Pivot d0 = (0 + dd), d30 = (30 + dd), d60 = (60 + dd), d90 = (90 + dd); // set servo positions and speeds needed to walk forward one step // (LFP, LBP, RBP, RFP, LFL, LBL, RBL, RFL, S1, S2, S3, S4) srv(a180, b0 , c120, d60, 42, 33, 33, 42, 1, 3, 1, 1); srv( a90, b30, c90, d30, 6, 33, 33, 42, 3, 1, 1, 1); srv( a90, b30, c90, d30, 42, 33, 33, 42, 3, 1, 1, 1); srv(a120, b60, c180, d0, 42, 33, 6, 42, 1, 1, 3, 1); srv(a120, b60, c180, d0, 42, 33, 33, 42, 1, 1, 3, 1); srv(a150, b90, c150, d90, 42, 33, 33, 6, 1, 1, 1, 3); srv(a150, b90, c150, d90, 42, 33, 33, 42, 1, 1, 1, 3); srv(a180, b0, c120, d60, 42, 6, 33, 42, 1, 3, 1, 1); //srv(a180, b0, c120, d60, 42, 15, 33, 42, 1, 3, 1, 1); }//== Back ==================================================================================void back (){ // set servo positions and speeds needed to walk backward one step // (LFP, LBP, RBP, RFP, LFL, LBL, RBL, RFL, S1, S2, S3, S4) srv(180, 0, 120, 60, 42, 33, 33, 42, 3, 1, 1, 1); srv(150, 90, 150, 90, 42, 18, 33, 42, 1, 3, 1, 1); srv(150, 90, 150, 90, 42, 33, 33, 42, 1, 3, 1, 1); srv(120, 60, 180, 0, 42, 33, 33, 6, 1, 1, 1, 3); srv(120, 60, 180, 0, 42, 33, 33, 42, 1, 1, 1, 3); srv(90, 30, 90, 30, 42, 33, 18, 42, 1, 1, 3, 1); srv(90, 30, 90, 30, 42, 33, 33, 42, 1, 1, 3, 1); srv(180, 0, 120, 60, 6, 33, 33, 42, 3, 1, 1, 1);}//== Left =================================================================================void turn_left (){ // set servo positions and speeds needed to turn left one step // (LFP, LBP, RBP, RFP, LFL, LBL, RBL, RFL, S1, S2, S3, S4) srv(150, 90, 90, 30, 42, 6, 33, 42, 1, 3, 1, 1); srv(150, 90, 90, 30, 42, 33, 33, 42, 1, 3, 1, 1); srv(120, 60, 180, 0, 42, 33, 6, 42, 1, 1, 3, 1); srv(120, 60, 180, 0, 42, 33, 33, 24, 1, 1, 3, 1); srv(90, 30, 150, 90, 42, 33, 33, 6, 1, 1, 1, 3); srv(90, 30, 150, 90, 42, 33, 33, 42, 1, 1, 1, 3); srv(180, 0, 120, 60, 6, 33, 33, 42, 3, 1, 1, 1); srv(180, 0, 120, 60, 42, 33, 33, 33, 3, 1, 1, 1);}//== Right ================================================================================void turn_right (){ // set servo positions and speeds needed to turn right one step // (LFP, LBP, RBP, RFP, LFL, LBL, RBL, RFL, S1, S2, S3, S4) srv( 90, 30, 150, 90, 6, 33, 33, 42, 3, 1, 1, 1); srv( 90, 30, 150, 90, 42, 33, 33, 42, 3, 1, 1, 1); srv(120, 60, 180, 0, 42, 33, 33, 6, 1, 1, 1, 3); srv(120, 60, 180, 0, 42, 33, 33, 42, 1, 1, 1, 3); srv(150, 90, 90, 30, 42, 33, 6, 42, 1, 1, 3, 1); srv(150, 90, 90, 30, 42, 33, 33, 42, 1, 1, 3, 1); srv(180, 0, 120, 60, 42, 6, 33, 42, 1, 3, 1, 1); srv(180, 0, 120, 60, 42, 33, 33, 42, 1, 3, 1, 1);}//== Center Servos ========================================================================void center_servos(){ myServo1.write(90); myServo2.write(90); myServo3.write(90); myServo4.write(90); myServo5.write(90); myServo6.write(90); myServo7.write(90); myServo8.write(90); int s11 = 90; // Front Left Pivot Servo int s12 = 90; // Front Left Lift Servo int s21 = 90; // Back Left Pivot Servo int s22 = 90; // Back Left Lift Servo int s31 = 90; // Back Right Pivot Servo int s32 = 90; // Back Right Lift Servo int s41 = 90; // Front Right Pivot Servo int s42 = 90; // Front Right Lift Servo}//== Increase Speed ========================================================================void increase_speed(){ if (spd > 3) spd--;}//== Decrease Speed ========================================================================void decrease_speed(){ if (spd < 50) spd++;}//== Srv ===================================================================================void srv( int p11, int p21, int p31, int p41, int p12, int p22, int p32, int p42, int sp1, int sp2, int sp3, int sp4){ // p11: Front Left Pivot Servo // p21: Back Left Pivot Servo // p31: Back Right Pivot Servo // p41: Front Right Pivot Servo // p12: Front Left Lift Servo // p22: Back Left Lift Servo // p32: Back Right Lift Servo // p42: Front Right Lift Servo // sp1: Speed 1 // sp2: Speed 2 // sp3: Speed 3 // sp4: Speed 4 // Multiply lift servo positions by manual height adjustment p12 = p12 + high * 3; p22 = p22 + high * 3; p32 = p32 + high * 3; p42 = p42 + high * 3; while ((s11 != p11) || (s21 != p21) || (s31 != p31) || (s41 != p41) || (s12 != p12) || (s22 != p22) || (s32 != p32) || (s42 != p42)) { // Front Left Pivot Servo if (s11 < p11) // if servo position is less than programmed position { if ((s11 + sp1) <= p11) s11 = s11 + sp1; // set servo position equal to servo position plus speed constant else s11 = p11; } if (s11 > p11) // if servo position is greater than programmed position { if ((s11 - sp1) >= p11) s11 = s11 - sp1; // set servo position equal to servo position minus speed constant else s11 = p11; } // Back Left Pivot Servo if (s21 < p21) { if ((s21 + sp2) <= p21) s21 = s21 + sp2; else s21 = p21; } if (s21 > p21) { if ((s21 - sp2) >= p21) s21 = s21 - sp2; else s21 = p21; } // Back Right Pivot Servo if (s31 < p31) { if ((s31 + sp3) <= p31) s31 = s31 + sp3; else s31 = p31; } if (s31 > p31) { if ((s31 - sp3) >= p31) s31 = s31 - sp3; else s31 = p31; } // Front Right Pivot Servo if (s41 < p41) { if ((s41 + sp4) <= p41) s41 = s41 + sp4; else s41 = p41; } if (s41 > p41) { if ((s41 - sp4) >= p41) s41 = s41 - sp4; else s41 = p41; } // Front Left Lift Servo if (s12 < p12) { if ((s12 + sp1) <= p12) s12 = s12 + sp1; else s12 = p12; } if (s12 > p12) { if ((s12 - sp1) >= p12) s12 = s12 - sp1; else s12 = p12; } // Back Left Lift Servo if (s22 < p22) { if ((s22 + sp2) <= p22) s22 = s22 + sp2; else s22 = p22; } if (s22 > p22) { if ((s22 - sp2) >= p22) s22 = s22 - sp2; else s22 = p22; } // Back Right Lift Servo if (s32 < p32) { if ((s32 + sp3) <= p32) s32 = s32 + sp3; else s32 = p32; } if (s32 > p32) { if ((s32 - sp3) >= p32) s32 = s32 - sp3; else s32 = p32; } // Front Right Lift Servo if (s42 < p42) { if ((s42 + sp4) <= p42) s42 = s42 + sp4; else s42 = p42; } if (s42 > p42) { if ((s42 - sp4) >= p42) s42 = s42 - sp4; else s42 = p42; } // Write Pivot Servo Values myServo1.write(s11 + da); myServo3.write(s21 + db); myServo5.write(s31 + dc); myServo7.write(s41 + dd); // Write Lift Servos Values myServo2.write(s12); myServo4.write(s22); myServo6.write(s32); myServo8.write(s42); delay(spd); // Delay before next movement }//while} //srv//== USRF Function ========================================================================long get_distance(bool unit){ // if unit == 0 return inches, else return cm long duration = 0, cm = 0, inches = 0; // The sensor is triggered by a HIGH pulse of 10 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: digitalWrite(trigPin, LOW); delayMicroseconds(5); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the signal from the sensor: 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(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); // convert the time into a distance cm = (duration / 2) / 29.1; inches = (duration / 2) / 74; if (unit == INCH) return inches; else return cm;}
These movements defined to the control are the movements defined in the arduino code before. You can define the idle pins of the controller in the code according to your own wishes.
Each remote has its own unique ID numbers. In order to introduce your own remote to your robot, you need to know the ID number of the buttons of your remote. In this, you need to download the code at the bottom to your Arduino first, learn the ID number of your remote's keys one by one, and copy it into your main code.