Introduction: LEGO 3D Printer Using Gcode

About: I'm a Mindstorms youtuber. I'm trying to learn to code Mindstorms with Python.

*I have a new instructables with an inproved code! go check it out:

Do you want to make your own 3D printer that can print every 3D file? Use this page or my site for the instructions!

For more detailed instructions:



LEGO Technic

Mindstorms EV3 brick + batteries

4 Mindstorms Medium and Large Motors

SD card

3D pen - I used this one, but I live in the Netherlands.

Laptop or pc (for programming)

Step 1: About

I was 12 years old when I made my first LEGO 3D printer. It was programmed using the Mindstorms EV3 Home Edition software. If I wanted to print a cube, I simply had to program the steps, and it got printed out!

Now, i'm 14 years old and made an improved version! It is programmed in Visual Studio Code using MicroPython and a SD card with the MicroPython Image.

So this are the instructions for one of the few LEGO 3D printers that can actually print 3d drawings, without having to program every model step by step!

If you would like to make this 3D printer, visit my Site for the more detailed instructions!

P.S. I would like it if you would let me know if you are going to make this project and if you got questions!

Step 2: Building

I'm not going to link building instructions, as my 3D printer isn't the best design possible.There are a lot of improvements to be done! If you haven't build your LEGO Mindstorms 3D printer yet, here are some tips:

1. Make sure you build a solid structure, because the smallest amount of movement, will make a big difference in the end result.

2. Move your platform from two opposite sides per axis. Don't try moving it with just one gear on one side, because the platfom won't move in a straight line, and may get stuck. You can simply make an axle going underneath the platform and connect it to the platform with some gears. Another option is to move the platform with linear actuators attached to the middle of a side.

3. If you work with gears, make a gear transmission, that reduces the amount the platform moves, in all three directions. (I haven't done this, but i should have) I recommend only one transmission per axis, as the platform would go to slow if you made more transmissions.

4. Make sure you use two the same motors with the same transmissions to move your platform. The code is programmed to work with two the same motors, because the medium and large motor move at a different speed. When you use two different motors, the code won't work propperly and your prints will fail.

5. Build a mechanism that can push the extruderbutton on the 3d pen. It will prevent getting loose threads.

Step 3: Setting Up MicroPython and Programs

First you need to download all the programs for the Mindstorms 3D printer:

Visual Studio Code

The EV3 MicroPython micro SD card image


Code + Files

After installing balenaEtcher and the EV3 MicroPython SD card image, you need to flash the SD card with the image.
Check the getting started guide from MINDSTORMS Education EV3 MicroPython.

After you've done this, follow the instructions about setting up Visual Studio Code with the MicroPython Extension.

Step 4: Programming


You can change these things in the program, to make the code work with your 3D printer:

:portSelection - You can define the ports in wich the motors are put into.

:startposition - If your 3D printer starts at an offsetpoint, change the numbers to your offsetpoint.

:degreestomm - Give the amount a motor has to turn, in order to move 1mm. (you may have to increase or decrease them a little bit)

:motorSpeed - The speed at wich the motors have to turn. (I recommend putting it low) Scale: 0 - 1000(you should keep the max speed 900)

:filename - Change this to select wich gcode file the program has to read and run.

After you've changed these variables, you need to prepare your gcode files. (Go down)

Step 5: Adding Gcode Files


Now you can put your Gcode file into the folder of the code.

You have to change these things in order for the program to work:

1. replace all ; with #; (making use of ctrl. + f)

2. replace all G, X, Y, Z, E, F, M and S with G;, X;, Y;, Z;, E;, F;, M; and S; (making use of ctrl. + f)

3. Start the file with: G;0 X;0 Y;0 Z;0 E;0 F;0

4. Replace the settings on the end of the file with: G;END E;0 (Without the replace tool)

Step 6: Printing!

Hit Run and Watch your 3d model being printed!

If you got questions, or if you are going to build this project, let me know down here!

or: mail me!