Tart Robotics
Published © GPL3+

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

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

BeginnerFull instructions provided2 hours8,965
A DIY Hexapod Robot with Arduino, Lego, and 3D Printed Parts

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
You can use any other type of Arduino as long as it supports enough I/O pins.
×1
Jumper wires (generic)
Jumper wires (generic)
×2
Toggle Switch, (On)-Off-(On)
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
4xAA battery holder
4xAA battery holder
Any other 6 to 9 volts DC power supply will also do the job.
×1
AA Batteries
AA Batteries
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Electrical Circuit Assembly

This is the basic electrical circuit assembly. You can enhance this by adding different Arduino modules and sensors.

Code

Hexapod Demo Arduino Code

C/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);
}

Credits

Tart Robotics

Tart Robotics

15 projects • 49 followers
Our mission is to provide children with novel robotic tools, to inspire them to become future innovators.

Comments