Skip to content

Instantly share code, notes, and snippets.

@ljunqian ljunqian/movement.txt
Last active Feb 26, 2017

Embed
What would you like to do?
Simple quadruped movement
#include <Servo.h>
/*
hip1 = front left hip
knee1 = front left knee
hip2 = rear left hip
knee2 = rear left knee
hip3 = rear right hip
knee31 = rear right knee
hip4 = front right hip
knee41 = front right knee
*/
Servo hip1;
Servo knee1;
Servo hip2;
Servo knee2;
Servo hip3;
Servo knee3;
Servo hip4;
Servo knee4;
//////////////////////////////////////
void setup()
{
hip1.attach(0);
hip1.write(60);
knee1.attach(1);
knee1.write(170);
hip2.attach(2);
hip2.write(120);
knee2.attach(3);
knee2.write(10);
hip3.attach(4);
hip3.write(70);
knee3.attach(5);
knee3.write(180);
hip4.attach(6);
hip4.write(120);
knee4.attach(7);
knee4.write(30);
}
//////////////////////////////////////
void forward()
{
knee1.write(170-20);
knee3.write(180-20);
delay(300);
hip1.write(60-20);
hip3.write(70-20);
delay(300);
knee1.write(170);
knee3.write(180);
delay(300);
hip1.write(60);
hip3.write(70);
delay(300);
knee2.write(10+20);
knee4.write(30+20);
delay(300);
hip2.write(120+20);
hip4.write(120+20);
delay(300);
knee2.write(10);
knee4.write(30);
delay(300);
hip2.write(120);
hip4.write(120);
delay(300);
}
/////////////////////////////////////
void loop()
{
forward();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.