Project tutorial
A DIY Hexapod Robot with Arduino, Lego, and 3D Printed Parts

A DIY Hexapod Robot with Arduino, Lego, and 3D Printed Parts © GPL3+

A programmable 6-legged robot with Lego, Arduino, and two off-the-shelf DC gear-motors for project-based STEM learning.

  • 5,479 views
  • 0 comments
  • 17 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
You can use any other type of Arduino as long as it supports enough I/O pins.
×1
11026 02
Jumper wires (generic)
×2
4765634
Toggle Switch, (On)-Off-(On)
×1
L298N mini dual DC motor driver
You can also use any other type of DC dual-driver motors like TB6612FNG or L298.
×1
TT DC 1:120 gear-motor
×2
Screw M3 30mm
×4
Nut M3
×4
mini breadboard
×1
Adafruit industries ada830 image 75px
4xAA battery holder
Any other 6 to 9 volts DC power supply will also do the job.
×1
61vhxtmzbyl
AA Batteries
×1

Necessary tools and machines

09507 01
Soldering iron (generic)
3drag
3D Printer (generic)

Apps and online services

About this project

Introduction

Legged robots have always been one of the most interesting creations in the robotic industry as they could help us in exploring mysterious lunar caves and other space  exploration missions. In fact, legged robots are mobile robots with articulated leg mechanisms that provide locomotion on rough trains. As compared with wheeled robots,   they can move on different terrains, although, at a slower speed.

Legged robots are often complicated to make and control, as it requires precise control of each leg to maintain balance. In this project, we are aiming to make a fun and easy-to-build six-legged robot with LEGO Technic components and an Arduino board (Fig A).

To do so, we took advantage of interesting mechanical mechanisms that simulate the walking pattern of a six-legged insect, with only one or two DC gear motors. The  result came up pretty interesting and pleasing to watch. Don't forget to follow our step-by-step instructions outlined below, and let us know what you think about this  subject by commenting below. Your feedback will help us to improve our future work.

Fig A - Electrical assembly

In this tutorial, we will show you how to build a robotic hexapod, a six-legged robot, that can walk similar to an insect (Fig B). You will make the body and the leg mechanisms of the robot using LEGO Technic parts. Then, commercially available DC gear motors will be connected to the leg mechanism to move the legs.

In the next step, you will need to add a brain to your robot to control its motions. Therefore, we will use Arduino UNO as an intelligent brain (Fig C). Arduino enables you to expand your hexapod’s possibilities with various commercially available motors, sensors, shields, and modules.

The hexapod is made in two different fashions. The first design uses one DC gear motor to move the hexapod back and forth (Fig D), and the second one is driven by two DC gear motors to enhance the maneuverability of the robot (Fig E).

You can do a variety of different tasks with your hexapod. You can tell the hexapod to track a path by programming your Arduino board. Add a couple of your favorite sensors or even simply control it with a remote joystick,similar to an RC car.

Materials

  • L298N Mini Motor Driver
  • Lego Compatible Coupling
  • Mini Toggle Switch
  • Bread Boards
  • Jumper Wire
  • M3 Nut
  • M3 Screw
  • Battery
  • Yellow Gear Motor
  • Battery Holder
  • Arduino Uno
  • Angular block 2, 180°
  • Double cross block, 3-module
  • Beam, 3-module
  • Angular beam, 3x5 module
  • Beam, 7-module
  • Beam, 13-module
  • Frame, 5x7-module
  • Angular block 1, 0°
  • Axle, 2-module
  • Gear, 8-tooth
  • Bushing, 1/2 module
  • Gear, 24-tooth
  • Axle, 6-module
  • Axle, 3-module
  • Connector peg, 2-module
  • Connector peg with friction, 2-module
  • Connector peg, 3-module
  • Connector peg with axle, 2-module
  • Connector peg with friction/axle, 2-module
  • Bushing, 1-module
  • Axle connector with axle hole
  • Beam with crosshole, 2-module

Assembly of Mechanical Parts

First, let’s assemble our hexapod’s body and leg mechanisms. Prepare the Lego pieces according to Fig. F, and follow the step-by-step video tutorial below.

Mechanical Parts Assembly Tutorial

3D-printed Parts

Lego Technic components only match with Lego gear motors. In order to connect the shafts of the commercially available gear motors to Lego components, we need to 3D print a coupling that makes the motor shaft compatible with its Lego counterpart. This is called Lego-compatible motor shaft coupling (Fig. G). So, go ahead and download the Lego-Compatible Motor Shaft Coupling 3D-print file. Then, find a 3D printer nearby or use yours.

Electronics and Wiring

Grab your screwdriver, warm up your soldering iron, and follow the video instruction below. Don’t forget to carefully implement the circuit diagram, so you don’t end up toasting your precious Arduino board.

Electrical Parts Assembly Tutorial

Programming

And last but not least, is the intelligent brain of your hexapod. Although you can do more development with the mechanical and the electrical parts of your hexapod. Programming is indeed the part that you can be most creative at. For now, let’s start with this code.

#define M1 11
#define M12 10
#define M2 9
#define M22 5

void setup() {
// Initialize Arduino pins to outputs
pinMode(M1, OUTPUT);
pinMode(M12, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(M22, OUTPUT);
}

void loop() {
goForward();
delay(3000);
goBackward();
delay(3000);
turnLeft();
delay(3000);
turnRight();
delay(3000);
}

// Configures driver motor pins to go forward.
void goForward() {
digitalWrite(M1, LOW);
analogWrite(M12, 200);
analogWrite(M2, 200);
digitalWrite(M22, LOW);
}

// Configures driver motor pins to go backward.
void goBackward() {
digitalWrite(M12, LOW);
analogWrite(M1, 200);
analogWrite(M22, 200);
digitalWrite(M2, LOW);
}

// Configures driver motor pins to turn left.
void turnLeft() {
digitalWrite(M12, LOW);
analogWrite(M1, 200);
analogWrite(M2, 200);
digitalWrite(M22, LOW);
}

// Configures driver motor pins to turn right.
void turnRight() {
digitalWrite(M1, LOW);
analogWrite(M12, 200);
analogWrite(M22, 200);
digitalWrite(M2, LOW);
}

Run Your Hexapod

Complete Hexapod

Code

Hexapod Demo Arduino CodeC/C++
This is a quick demo code that moves the robots in different directions.
/*
  Hexpod Walking Robot
    The idea:
    In this tutorail, we will show you how to build a robotic hexapod, a six-legged robot,
    that can walk similar to an insect. You will make the body and the leg mechanisms of the
    robot using Lego Technic parts. Then, commercially available DC gear motors will be
    connected to the leg mechanism to move the legs.
    The circuit:
    - In this circuit, an Arduino nano is used. Any other types of Arduino
    can be used. Do not forget to change the pin configurations
    if you want to change the Arduino on your preference.
    Visit Tart Robotics blog for more information:
    https://www.tartrobotics.com/blog
*/

#define M1 11
#define M12 10
#define M2 9
#define M22 5 


void setup() {
  // Initialize Arduino pins to outputs
  pinMode(M1, OUTPUT);
  pinMode(M12, OUTPUT);
  pinMode(M2, OUTPUT);
  pinMode(M22, OUTPUT);
}

void loop() {
  goForward();
  delay(3000);

  goBackward();
  delay(3000);

  turnLeft();
  delay(3000);

  turnRight();
  delay(3000);
}

// Configures driver motor pins to go forward.
void goForward() {
  digitalWrite(M1, LOW);
  analogWrite(M12, 200);
  analogWrite(M2, 200);
  digitalWrite(M22, LOW);
}

// Configures driver motor pins to go backward.
void goBackward() {
  digitalWrite(M12, LOW);
  analogWrite(M1, 200);
  analogWrite(M22, 200);
  digitalWrite(M2, LOW);
}

// Configures driver motor pins to turn left.
void turnLeft() {
  digitalWrite(M12, LOW);
  analogWrite(M1, 200);
  analogWrite(M2, 200);
  digitalWrite(M22, LOW);
}

// Configures driver motor pins to turn right.
void turnRight() {
  digitalWrite(M1, LOW);
  analogWrite(M12, 200);
  analogWrite(M22, 200);
  digitalWrite(M2, LOW);
}

Schematics

Electrical Circuit Assembly
This is the basic electrical circuit assembly. You can enhance this by adding different Arduino modules and sensors.
Wiring diagram a0pqomx5kv

Comments

Similar projects you might like

A DIY Zipline Robot with Arduino, Lego, and 3D Printed Parts

Project tutorial by Tart Robotics

  • 4,859 views
  • 2 comments
  • 23 respects

A DIY Biped Robot with Arduino, Lego, and 3D Printed Parts

Project tutorial by Tart Robotics

  • 4,595 views
  • 2 comments
  • 11 respects

A DIY Remote-Controlled Rescue Robot with Arduino and Lego

Project tutorial by Tart Robotics

  • 3,978 views
  • 2 comments
  • 13 respects

Otto DIY build your own robot in one hour!

Project tutorial by Camilo Parra Palacio

  • 193,767 views
  • 140 comments
  • 461 respects

Otto DIY+ Arduino Bluetooth robot easy to 3D Print

Project tutorial by Team Otto builders

  • 95,329 views
  • 136 comments
  • 239 respects

Quadruped Robot

Project tutorial by Tart Robotics

  • 7,582 views
  • 2 comments
  • 26 respects
Add projectSign up / Login