From e765a32fd232e167d7d15eb8142a706740f42ad2 Mon Sep 17 00:00:00 2001 From: Kython89 Date: Tue, 24 Nov 2015 20:35:14 -0600 Subject: [PATCH 1/2] Initial Commit (reverted from commit 99101aa3781d2012d848d6ea05e30f1a070b876a) --- Hexapod.ino | 100 ---------------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 Hexapod.ino diff --git a/Hexapod.ino b/Hexapod.ino deleted file mode 100644 index bd303a9..0000000 --- a/Hexapod.ino +++ /dev/null @@ -1,100 +0,0 @@ -#include - -#define MID_LEG_MID 95 -#define MID_LEG_MAX 115 -#define MID_LEG_MIN 75 - -#define LEFT_LEG_MID 90 -#define LEFT_LEG_MAX 125 -#define LEFT_LEG_MIN 45 - -#define RIGHT_LEG_MID 90 -#define RIGHT_LEG_MAX 125 -#define RIGHT_LEG_MIN 45 - -#define MID_LEG_LIFT_RIGHT MID_LEG_MAX -#define MID_LEG_LIFT_LEFT MID_LEG_MIN - -#define LEFT_LEG_FWD LEFT_LEG_MIN -#define LEFT_LEG_REV LEFT_LEG_MAX - -#define RIGHT_LEG_FWD RIGHT_LEG_MAX -#define RIGHT_LEG_REV RIGHT_LEG_MIN - -Servo midLeg; -Servo leftLeg; -Servo rightLeg; - -void setup() { - // put your setup code here, to run once: - midLeg.attach(3); - leftLeg.attach(5); - rightLeg.attach(6); -} -bool first = 1; -void loop() { - // put your main code here, to run repeatedly: - if (first) { - first = 0; - //setMidLeg(MID_LEG_LIFT_LEFT); - walkFwd(); - walkFwd(); - walkFwd(); - - delay(5000); - zeroLegs(); - } - -} - -void zeroLegs() { - setMidLeg(MID_LEG_LIFT_LEFT); - delay(500); - setLeftLeg(LEFT_LEG_MID); - delay(200); - - setMidLeg(MID_LEG_LIFT_RIGHT); - delay(500); - setRightLeg(RIGHT_LEG_MID); - delay(200); - - setMidLeg(MID_LEG_MID); -} - -void walkFwd() { - setMidLeg(MID_LEG_LIFT_RIGHT); - delay(500); - setRightLeg(RIGHT_LEG_FWD); - setLeftLeg(LEFT_LEG_REV); - delay(500); - setMidLeg(MID_LEG_LIFT_LEFT); - delay(500); - setRightLeg(RIGHT_LEG_REV); - setLeftLeg(LEFT_LEG_FWD); - delay(500); -} - -void walkRev() { - //TODO: Implement -} - -void walkLeft() { - //TODO: Implement -} - -void walkRight() { - //TODO: Implement -} - -void setMidLeg(int val) { - midLeg.write(constrain(val, MID_LEG_MIN, MID_LEG_MAX)); -} - -void setLeftLeg(int val) { - leftLeg.write(constrain(val, LEFT_LEG_MIN, LEFT_LEG_MAX)); -} - -void setRightLeg(int val) { - rightLeg.write(constrain(val, RIGHT_LEG_MIN, RIGHT_LEG_MAX)); -} - From 5b2f38a3584553a8fbf129000d41ee34c3c1ba60 Mon Sep 17 00:00:00 2001 From: Kython89 Date: Tue, 24 Nov 2015 20:35:36 -0600 Subject: [PATCH 2/2] Initial Commit (reverted from commit 99101aa3781d2012d848d6ea05e30f1a070b876a) (reverted from commit e765a32fd232e167d7d15eb8142a706740f42ad2) --- Hexapod.ino | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Hexapod.ino diff --git a/Hexapod.ino b/Hexapod.ino new file mode 100644 index 0000000..bd303a9 --- /dev/null +++ b/Hexapod.ino @@ -0,0 +1,100 @@ +#include + +#define MID_LEG_MID 95 +#define MID_LEG_MAX 115 +#define MID_LEG_MIN 75 + +#define LEFT_LEG_MID 90 +#define LEFT_LEG_MAX 125 +#define LEFT_LEG_MIN 45 + +#define RIGHT_LEG_MID 90 +#define RIGHT_LEG_MAX 125 +#define RIGHT_LEG_MIN 45 + +#define MID_LEG_LIFT_RIGHT MID_LEG_MAX +#define MID_LEG_LIFT_LEFT MID_LEG_MIN + +#define LEFT_LEG_FWD LEFT_LEG_MIN +#define LEFT_LEG_REV LEFT_LEG_MAX + +#define RIGHT_LEG_FWD RIGHT_LEG_MAX +#define RIGHT_LEG_REV RIGHT_LEG_MIN + +Servo midLeg; +Servo leftLeg; +Servo rightLeg; + +void setup() { + // put your setup code here, to run once: + midLeg.attach(3); + leftLeg.attach(5); + rightLeg.attach(6); +} +bool first = 1; +void loop() { + // put your main code here, to run repeatedly: + if (first) { + first = 0; + //setMidLeg(MID_LEG_LIFT_LEFT); + walkFwd(); + walkFwd(); + walkFwd(); + + delay(5000); + zeroLegs(); + } + +} + +void zeroLegs() { + setMidLeg(MID_LEG_LIFT_LEFT); + delay(500); + setLeftLeg(LEFT_LEG_MID); + delay(200); + + setMidLeg(MID_LEG_LIFT_RIGHT); + delay(500); + setRightLeg(RIGHT_LEG_MID); + delay(200); + + setMidLeg(MID_LEG_MID); +} + +void walkFwd() { + setMidLeg(MID_LEG_LIFT_RIGHT); + delay(500); + setRightLeg(RIGHT_LEG_FWD); + setLeftLeg(LEFT_LEG_REV); + delay(500); + setMidLeg(MID_LEG_LIFT_LEFT); + delay(500); + setRightLeg(RIGHT_LEG_REV); + setLeftLeg(LEFT_LEG_FWD); + delay(500); +} + +void walkRev() { + //TODO: Implement +} + +void walkLeft() { + //TODO: Implement +} + +void walkRight() { + //TODO: Implement +} + +void setMidLeg(int val) { + midLeg.write(constrain(val, MID_LEG_MIN, MID_LEG_MAX)); +} + +void setLeftLeg(int val) { + leftLeg.write(constrain(val, LEFT_LEG_MIN, LEFT_LEG_MAX)); +} + +void setRightLeg(int val) { + rightLeg.write(constrain(val, RIGHT_LEG_MIN, RIGHT_LEG_MAX)); +} +