A DIY Quadruped Robot With Arduino, 3D Printed, and Lego-compatible Parts




Introduction: A DIY Quadruped Robot With Arduino, 3D Printed, and Lego-compatible Parts

About: We are an incorporated company located in Toronto Canada. Our team includes professional experts in mechatronics, science, mathematics, art, and business marketing to develop world-class STEAM-based educationa…


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 be made and controlled, as it requires precise control of each leg to maintain its balance. In this project, we are aiming to make a fun and easy-to-build four-legged robot with Lego-compatible and an Arduino board. To do so, we take advantage of interesting mechanical mechanisms that simulate the walking pattern of a real animal, with only one DC gear motor. The result is quite interesting.

Step 1: General View of the Quadruped Robot

In this tutorial, we will make the body and the leg mechanisms of the robot using Lego-compatible parts. Then, an off-the-shelf DC gear motor will be connected to the leg mechanism to move the legs.

In the next step, we will need to add a brain to our robot to control its motions. Therefore, we will use Arduino Nano as an intelligent brain. Arduino enables us to expand our Quadruped’s possibilities with various commercially available motors and sensors.

Step 2: Electrical Assembly

To enhance the performance of the robot, we used an ultrasonic sensor as the eyes of the robot. By using the ultrasonic sensor, the robot can avoid obstacles. Thanks to the open-source nature of the Arduino board that allows such developments.

Step 3: Materials

List of electronic parts

A) TT Gear Motor

B) 3D Printed Gear Motor Housing

C) 1x Arduino Nano

D) 1x Breadboard, Mini Size

E) 1x Power Jack, Barrel Type

F) 1x Ultrasonic Sensor

G) 3D Printed Lego-compatible Coupling


I) 1x M3 x 25 Machine Screw

J) 2x M3 x 10 Machine Screw

List of Lego Technic components

A) Frame, 5x7 module

B) Gear, 40-tooth

C) Gear, 24-tooth

D) Gear, 20-tooth and double bevel

E) Bevel gear, 12-tooth

F) Gear, 8-tooth

G) Beam, 9-module

H) Beam, 5-module

I) Beam, 3-module

J) Angular beam, 3x5 module

K1) Axle, 7-module

K2) Axle, 6-module

K3) Axle with stop, 4-module

K4) Axle, 3-module

L) Bushing/axle extender, 2-module

M) T-Beam, 3x3 module

N) Angular block 2, 180°

O) Connector peg with friction, 3-module

P1) Connector peg with friction, 2-module

P2) Connector peg with friction/axle, 2-module

Q) Beam with cross hole, 2-module

R) Double cross block, 3-module

S) Bushing, 1-module

T) Axle and pin connector perpendicular

U) Connector peg with axle, 2-module

V) Bushing, 1/2 module

W) Angular block 1, 0°

X) Axle connector with axle hole

Y) Angular block, 6 (90°)

Z1) Liftarm, 2 x 4 L-Shape Thick

Z2) Universal Joint 3L

Z3) Axle, 2-module

Step 4: Assembly of Mechanical Parts

Let’s start off by assembling the body structure and leg mechanisms of the Quadruped robot. The body structure holds everything together, including the gears, Legs, and electronics. Prepare the Lego-compatible pieces according to the part list, and follow the step-by-step video tutorial below.

Step 5: 3D Printed Parts

In order to hold the DC gear motor in place and make a proper connection to the Lego-compatible pieces, we have used custom-designed, Lego-compatible, 3D printed motor housings and shaft couplings. Download and print out the motor housings, couplings. Then prepare the required Lego-compatible parts from the part list, and follow the step-by-step mechanical assembly tutorial.

Step 6: Electronics and Wiring

Prepare your screwdriver and soldering iron and carefully follow the video instructions below. Make sure you properly implement the schematic circuit diagram so you don't end up toasting your Arduino board and motor driver.

Step 7: Programming

You can pick up Lego-compatible pieces and let your imagination go limitless. Of course, coding is also the part that you can have lots of fun and be the most creative. You can go to Arduino IDE and write your own code to tell the Quadruped robot to do. But for now, let's start with this code.

  Quadruped robot
    The idea:
    In this project, we will show you how to make a  quadruped robot out of Lego-compatible pieces,
    Arduino boards, off-the-shelf DC motor, and ultrasonic sensor.
    The current project uses an Arduino Nano boards as the main controller of the
    The circuit:
    - In this circuit, an Arduino Nano is used. Any other types of Arduino
    can be used of course but do not forget to change the pin configurations
    if you want to change the circuit on your preference.
    Visit the Tart Robotics blog for more information:


#define VCC 4            // This pin define as Vcc
#define TRIG 5           // Ultrasonic sensor Trig pin
#define ECHO 6         // Ultrasonic sensor Echo pin
#define GND 7           // This pin define as GND
#define MOTOR 3      // Motor pin

const int dist = 15;     // Desired distance in cm

float duration, distance;

void setup() {
  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);

  pinMode(VCC, OUTPUT);
  pinMode(GND, OUTPUT);

  digitalWrite(VCC, HIGH);
  digitalWrite(GND, LOW);

void loop() {
//  This section is related to Ultrasonics sensor
 digitalWrite(TRIG, LOW);
 digitalWrite(TRIG, HIGH);
 digitalWrite(TRIG, LOW);
 duration = pulseIn(ECHO, HIGH);
 distance = (duration * .0343) / 2;
  if (distance < dist)
    analogWrite(MOTOR, 200);
    analogWrite(MOTOR, 0);

  analogWrite(MOTOR, 200);

You are all set. Your robot is ready to go.

Please let us know what you think about this tutorial by commenting below. Your feedback will help us to improve our future work.

Please visit Tart Robotics for more DIY creative projects and STEAM-related educational content. Our Socials: Tart Robotics website, YouTube, Instagram, Facebook, Twitter, Pinterest

Be the First to Share


    • Reclaimed Materials Contest

      Reclaimed Materials Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Cookie Speed Challenge

      Cookie Speed Challenge



    9 months ago

    Very nice project!!! I wanted to use DC motors just like the one you used with lego and I have been trying to figure out how to make it Lego-compatible. Thanks for providing the 3D object files!

    Tart Robotics
    Tart Robotics

    Reply 6 months ago

    Hi Themelispan! Thank you so much for your interest in Quadruped Robot. All the best.


    Question 10 months ago on Introduction

    Hello, can you give the number of each element of the LEGO pieces?thank you in


    10 months ago

    Very cool! Looking forward to making this with my son. Thanks for the detailed plan. Might be nice to mention that you require people to sign up in order to get the 3D plans :-) I have though, because your other projects look great too.

    Tart Robotics
    Tart Robotics

    Reply 10 months ago

    Thank you so much. Very glad that you like our projects. Please check out our Instagram page @tartrobotics for many more STEM-related and DIY robotic projects.