Project in progress
MEGA BREAD - Hank the HexaPod-Updated 5-31-17

MEGA BREAD - Hank the HexaPod-Updated 5-31-17 © MIT

A 6 legged, 18 servo, self guiding time wasting project. MEGA BREAD series #7, Delivery and retrieval from the air project.

  • 1,764 views
  • 1 comment
  • 13 respects

Components and supplies

About this project

UPDATED 5-31-2017

  • Added more and new code.
  • Added new youtube video

Well to start with, The MEGA BREAD series is for my son to begin learning robotics. This thingamabob will walk around, detect obstacles, and accept Bluetooth when completed fully.

Other plans for this bot include: Remote delivery and pickup using GPS and a hefty race Quad Copter. Having the ability to land on top of the Hexapod, latch on using an Electromagnet, and fly off. The bot will then be delivered to your location of choosing.

This step will require the remainder of the summer to complete, But should win him a place in the local robotics competition.

This bot is controlled using old Atari Joysticks, and a radio transmitter/receiver setup.

Wish us luck....

Code

MEGA_BREAD_HANK_THE_HEXABOTArduino
/* MEGA BREAD -- SIGHT
###################################
# Datatypes (KEYWORD1)
###################################
NewPing  KEYWORD1
###################################
# Methods and Functions (KEYWORD2)
###################################
ping  KEYWORD2
ping_in KEYWORD2
ping_cm KEYWORD2
ping_median KEYWORD2
ping_timer  KEYWORD2
check_timer KEYWORD2
timer_us  KEYWORD2
timer_ms  KEYWORD2
timer_stop  KEYWORD2
convert_in  KEYWORD2
convert_cm  KEYWORD2
###################################
# Constants (LITERAL1)
###################################*/
#include <NewPing.h>
#define TRIGGER_PIN  53  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     52  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

/*SERVO SETUP - MEGA BREAD
  Usable pins on the MEGA
  Servos  analogWrite Pins  Timers used
  1 - 12  not pins 44,45,46 Timer 5
  13 - 24 not pins 11,12,44,45,46 Timers 1 & 5
  24 - 36 not pins 6,7,8,11,12,44,45,46 Timers 1,4 & 5
  37 - 48 not pins 2,3,5,6,7,8,11,12,44,45,46 Timers 1,3,4 & 5*/
#include <Servo.h>
int legCount = 6;
int servoSpeed = 2;
int delayTimeA = 50;
int delayTimeB = 100;
int trueMidPos = 90;
int minPos = 60;
int maxPos = 110;
int midPos = ((maxPos - minPos) / 2) + minPos;
int lPos = midPos;
int rPos = midPos;
int aSectionlSideModifier = 0;
int aSectionrSideModifier = -0;
int bSectionlSideModifier = 0;
int bSectionrSideModifier = -0;
int cSectionlSideModifier = 10;
int cSectionrSideModifier = -10;
Servo LFA;
Servo LFB;
Servo LFC;
int ServoPinLFA = 22;
int ServoPinLFB = 23;
int ServoPinLFC = 24;
Servo LMA;
Servo LMB;
Servo LMC;
int ServoPinLMA = 26;
int ServoPinLMB = 27;
int ServoPinLMC = 28;
Servo LRA;
Servo LRB;
Servo LRC;
int ServoPinLRA = 30;
int ServoPinLRB = 31;
int ServoPinLRC = 32;
Servo RFA;
Servo RFB;
Servo RFC;
int ServoPinRFA = 34;
int ServoPinRFB = 35;
int ServoPinRFC = 36;
Servo RMA;
Servo RMB;
Servo RMC;
int ServoPinRMA = 38;
int ServoPinRMB = 39;
int ServoPinRMC = 40;
Servo RRA;
Servo RRB;
Servo RRC;
int ServoPinRRA = 42;
int ServoPinRRB = 43;
int ServoPinRRC = 44;

void distanceCheck() {
  delay(delayTimeA); // Wait delayTimeB in MS. 29ms should be the shortest delay between pings.
  Serial.print("Ping: ");
  Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");
}


//Head Setup
Servo HeadTwist;
Servo HeadTilt;
int ServoPinHeadTwist = 46;
int ServoPinHeadTilt = 47;

// HEAD TWIST
void headTwist() {
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
//    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
//    constrain(rPos, minPos, maxPos);
    HeadTwist.write(lPos);
//    HeadTilt.write(rPos);
    delay(delayTimeA);
    distanceCheck();
  }
  
  delay(delayTimeB);
  for (lPos = minPos; lPos <= maxPos; lPos += servoSpeed) {
//    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
//    constrain(rPos, minPos, maxPos);
    HeadTwist.write(lPos);
//    HeadTilt.write(rPos);
    delay(delayTimeA);
    distanceCheck();
  }
  
}
// HEAD TILT
void headTilt() {
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
//    HeadTwist.write(lPos);
    HeadTilt.write(rPos);
    delay(delayTimeA);
  }
  
}

void AllLegsFlex() {
  // Forward Leg Swing
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(lPos);
    LMA.write(rPos);
    LRA.write(lPos);
    RFA.write(rPos);
    RMA.write(lPos);
    RRA.write(rPos);
    LFB.write(lPos);
    LMB.write(rPos);
    LRB.write(lPos);
    RFB.write(rPos);
    RMB.write(lPos);
    RRB.write(rPos);
    LFC.write(lPos);
    LMC.write(rPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(lPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
  // Rearward Leg Swing
  for (lPos = minPos; lPos <= maxPos; lPos += servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(lPos);
    LMA.write(rPos);
    LRA.write(lPos);
    RFA.write(rPos);
    RMA.write(lPos);
    RRA.write(rPos);
    LFB.write(lPos);
    LMB.write(rPos);
    LRB.write(lPos);
    RFB.write(rPos);
    RMB.write(lPos);
    RRB.write(rPos);
    LFC.write(lPos);
    LMC.write(rPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(lPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
}

void updownLegsFlex() {
  // Upward Leg Swing
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(lPos + bSectionlSideModifier);
    LMB.write(lPos + bSectionlSideModifier);
    LRB.write(lPos + bSectionlSideModifier);
    RFB.write(rPos + bSectionrSideModifier);
    RMB.write(rPos + bSectionrSideModifier);
    RRB.write(rPos + bSectionrSideModifier);
    LFC.write(lPos + cSectionlSideModifier);
    LMC.write(lPos + cSectionlSideModifier);
    LRC.write(lPos + cSectionlSideModifier);
    RFC.write(rPos + cSectionrSideModifier);
    RMC.write(rPos + cSectionrSideModifier);
    RRC.write(rPos + cSectionrSideModifier);
    delay(delayTimeA);
  }
  // Downward Leg Swing
  for (lPos = minPos; lPos <= maxPos; lPos += servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(lPos + bSectionlSideModifier);
    LMB.write(lPos + bSectionlSideModifier);
    LRB.write(lPos + bSectionlSideModifier);
    RFB.write(rPos + bSectionrSideModifier);
    RMB.write(rPos + bSectionrSideModifier);
    RRB.write(rPos + bSectionrSideModifier);
    LFC.write(lPos + cSectionlSideModifier);
    LMC.write(lPos + cSectionlSideModifier);
    LRC.write(lPos + cSectionlSideModifier);
    RFC.write(rPos + cSectionrSideModifier);
    RMC.write(rPos + cSectionrSideModifier);
    RRC.write(rPos + cSectionrSideModifier);
    delay(delayTimeA);
  }
}

void tipLegsFlex() {
  // tip out Leg Swing
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(midPos);
    LMB.write(midPos);
    LRB.write(midPos);
    RFB.write(midPos);
    RMB.write(midPos);
    RRB.write(midPos);
    LFC.write(lPos);
    LMC.write(lPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(rPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
  // tip in Leg Swing
  for (lPos = minPos; lPos <= maxPos; lPos += servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(midPos);
    LMB.write(midPos);
    LRB.write(midPos);
    RFB.write(midPos);
    RMB.write(midPos);
    RRB.write(midPos);
    LFC.write(lPos);
    LMC.write(lPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(rPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
}

void midLegsFlex() {
  // mid down Leg Swing
  for (lPos = maxPos; lPos >= minPos; lPos -= servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(midPos);
    LMB.write(midPos);
    LRB.write(midPos);
    RFB.write(midPos);
    RMB.write(midPos);
    RRB.write(midPos);
    LFC.write(lPos);
    LMC.write(lPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(rPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
  // mid up Leg Swing
  for (lPos = minPos; lPos <= maxPos; lPos += servoSpeed) {
    rPos = map(lPos, minPos, maxPos, maxPos, minPos);
    constrain(lPos, minPos, maxPos);
    constrain(rPos, minPos, maxPos);
    LFA.write(trueMidPos);
    LMA.write(trueMidPos);
    LRA.write(trueMidPos);
    RFA.write(trueMidPos);
    RMA.write(trueMidPos);
    RRA.write(trueMidPos);
    LFB.write(midPos);
    LMB.write(midPos);
    LRB.write(midPos);
    RFB.write(midPos);
    RMB.write(midPos);
    RRB.write(midPos);
    LFC.write(lPos);
    LMC.write(lPos);
    LRC.write(lPos);
    RFC.write(rPos);
    RMC.write(rPos);
    RRC.write(rPos);
    delay(delayTimeA);
  }
  delay(delayTimeB);
}

void setup() {
  Serial.begin(9600);
  LFA.attach(ServoPinLFA);
  LMA.attach(ServoPinLMA);
  LRA.attach(ServoPinLRA);
  RFA.attach(ServoPinRFA);
  RMA.attach(ServoPinRMA);
  RRA.attach(ServoPinRRA);
  LFB.attach(ServoPinLFB);
  LMB.attach(ServoPinLMB);
  LRB.attach(ServoPinLRB);
  RFB.attach(ServoPinRFB);
  RMB.attach(ServoPinRMB);
  RRB.attach(ServoPinRRB);
  LFC.attach(ServoPinLFC);
  LMC.attach(ServoPinLMC);
  LRC.attach(ServoPinLRC);
  RFC.attach(ServoPinRFC);
  RMC.attach(ServoPinRMC);
  RRC.attach(ServoPinRRC);
  HeadTwist.attach(ServoPinHeadTwist);
  HeadTilt.attach(ServoPinHeadTilt);
}

void loop() {
  //  AllLegsFlex();
  //delay(delayTimeB);
//  updownLegsFlex();
//delay(delayTimeB);
  // tipLegsFlex();
  //delay(delayTimeB);
  // midLegsFlex();
   headTwist();
   delay(delayTimeB);
//   headTilt();
// delay(delayTimeB);
//   distanceCheck();
// delay(delayTimeB);
}
MEGA BREAD - Hank the Hexabot CodeNix
Not yet published due to development issues for pickup and delivery of the bot from the air.
No preview (download only).

Schematics

MEGA BREAD - Hank the Hexabot
Assembly diagram
Mega bread hank the hexabot bb wqzap2fdpm

Comments

Similar projects you might like

MEGA BREAD - 4X4 KeyPad

Project in progress by Pigeon-Kicker

  • 2,795 views
  • 1 comment
  • 4 respects

Mega Bread - Atari Joystick Linking for Robotics Control

Project in progress by Pigeon-Kicker

  • 1,440 views
  • 3 comments
  • 10 respects

MEGA BREAD - Stereo Power Audio Amplifiers

Project in progress by Pigeon-Kicker

  • 1,514 views
  • 0 comments
  • 6 respects

Mega Bread - Hello World

Project in progress by Pigeon-Kicker

  • 1,573 views
  • 0 comments
  • 4 respects

Mega Solar Tracker

Project in progress by Team Trouble

  • 3,731 views
  • 0 comments
  • 32 respects

Arduino Mega Chess

Project showcase by Sergey_Urusov

  • 24,119 views
  • 53 comments
  • 118 respects
Add projectSign up / Login