DIY RepRap 3D Printer for Beginners – Part 3: Code

reprap 3d printer

reprap 3d printer

If you’re new to this project, please refer back to Part 1 and Part 2 of the project before proceeding further: DIY RepRap 3D Printer for Beginners – Part 1: Mechanics and DIY RepRap 3D Printer for Beginners – Part 2: Wiring.

In the last part of the DIY RepRap 3D printer series, we will configure belts and end stops, add LCD display, and lastly program codes to test the printer. Let’s get started!

Final printer specs:
Desktop Footprint: 11in x 13in x 13in
Maximum Build Space: 105mm x 130mm x 80mm


  • 3D Printer frame from Part 1
  • Arduino Mega
  • Ramps 1.4
  • SD card of any size
  • 5 x A4988 Stepper Motor Driver with Heatsink
  • 6 x mechanical end stops
  • 20 x male to female wires
  • Smart Full Graphic Display from Discount RepRap
  • Power Supply (12V 30A, OEM)
  • Three prong wall cord and connector
  • 6 x ¼” ring crimp connectors
  • Large gauge wire
  • Logic wire
  • Electrical tape
  • Tape, Velcro, or other cable management solutions


  • Arduino IDE
  • Marlin 3D printer Firmware
  • Cura 3D Printing Slicing Software


  • Soldering iron
  • Solder
  • Wire strippers
  • Crimpers


  1. Connect Belt Configuration
  2. Connect Mechanical Endstops
  3. Test All components
  4. Connecting the screen
  5. Download and Configure Marlin Firmware
  6. Finishing Touches
  7. Your First Print

Step 1: Connect Belt Configuration

The belt configuration for this tutorial is shown in Figure 1. Looking at this configuration may be confusing for some, so I’ll explain its purpose.

reprap 3d printer

Figure 1: Belt Configuration


The system uses two belts that each wrap around one stepper and connect to diagonals of the extruder sled. This means that when only one stepper is running, the belt moves diagonally. If both motors turn in the same direction, the extruder moves along the x- axis and if they turn in opposite directions, the extruder moves along the y axis. This allows the printer to move quickly across diagonal motion and therefore saves time and energy while printing.

In order to set up this configuration, cut the timing belt into 2 x 140 cm lengths. This is entirely dependent upon the size of your printer, so make sure to set up the belts and then cut size. Start with one side. Clamp one belt to a corner of the extruder sled. The final result should look like below (Figure 2).


reprap 3d printer

Figure 2: Printer with only one belt connected

Here are wrapping tricks:

  • Wrap the flat end around the bottom timing pulley in the stack.
  • Wrap the teeth-side of the belt around the timing pulley on the stepper.
  • Wrap the teeth side of the belt around the bottom bearings at the next two corners.
  • Wrap the teeth side around the bottom timing pulley and clamp it to the opposite diagonal.
  • Repeat on the other stepper using the top timing pulleys and bearings.


Step 2: Test All Components

Before going any further with this project, we’re going to test that all of the components work separately. Make sure that you have downloaded the Arduino IDE. Copy and paste the code below into the Arduino environment.



Step 3: Connect Mechanical End Stops

Mechanical end stops come in two varieties: two pin and three pin. In this tutorial, we use three pin end stops, but the installation for two pin end stops is much the same. For three pin end stops, plug the green signal wire into the S pin on ramps, the black ground wire into negative, and the red positive wire into positive.

reprap 3d printer

Figure 3: Mechanical Endstop connection


For two pin end stops, plug the red positive wire into the S pin on RAMPS and the black ground wire into negative. There should be 6 end stops: a maximum and a minimum for each axis. Figure 4 shows the RAMPS board after they are all connected.

reprap 3d printer

Figure 4: Mechanical EndStops Connection to RAMPS


The placement of the end stops may require some trial and error to find the perfect placement.


Step 4: Connecting the Screen

Take out your full graphic smart controller. Connect the two ribbon cables with the screen and the expansion board. Press the expansion board onto the tail end of ramps. Tape the screen onto the milk crate in a place that is out of the way of the mechanisms. Figure 5 below shows how thing are set up.

reprap 3d printer

Figure 5: View of Screen Placement


Step 5: Download and Configure Marlin

The Marlin Firmware is used to run the printer, rather than writing the entire code. It converts files into G-code, levels your print bed, and creates a user-friendly interface. The Marlin Firmware can be found here: Download the file and open it in the Arduino IDE.

Marlin can be used for many different applications, like RAMPS. As a result, there is some configuration we need to do.

First, let’s tell it what board we are using. This tutorial is written assuming that you are using RAMPS 1.4. If you are using another board, check the boards.h file in Marlin for the proper variable for your board. Open the Configuration.h file in Marlin.

Search for this line: #define MOTHERBOARD. Remove the initial condition and input 43, the number associated with the RAMPS 1.4 EFB board.

Search for this phrase: #define CUSTOM_MACHINE_NAME “3D Printer”. Change the machine name if you’d like.

Search for this phrase: #define MACHINE_UUID “00000000-0000-0000-0000-000000000000”. Change the UUID to a randomly generated UUID so that it can be a unique address for Bluetooth communication.

Search for this phrase: #define EXTRUDERS 1. Make sure this is set to one if you are using one extruder and 2 if you are using 2. Additionally, in this section, you can define other parameters for secondary extruders.

Search for this phrase: #define POWER_SUPPLY 1. If you are using an OEM power supply, replace the 1 with a zero. If you are using an ATX, keep the one. See the documentation for other power sources.

Search for this phrase: #define TEMP_SENSOR_0. This defines your thermistor resistance for the extruder. Most are 100 K and should be defined as 1. Check your documentation for the resistance value for your thermistor. The rest of the section can define all the rest of the thermistors that you may use.

Search for this phrase: #define HEATER_0_MINTEMP. This section decides the safe temperature ranges for the hot end. Make sure this section contains safe values.

Search for this phrase: #define EXTRUDE_MINTEMP 170. This means the printer will not move if the extruder is less than 170 degrees Celsius. This is important to remember if you have a thermistor problem.

Search for this phrase: #define THERMAL_PROTECTION_HOTENDS. Uncomment this line to enable a more intelligent heat control. This feature measures the temperature with the thermistor and then sets a timer. If the temperature has gone up significantly since that measurement, it stops the print. This protects against loose thermistors that can cause the printer to overheat.

Search for the phrase: #define COREXY. This is the name of the belt configuration that is used in this tutorial. There are other special configurations that can also be set in this section.

Search for this phrase: #define INVERT_X_DIR. This section allows you to change the direction of any axis. It may be useful for debugging.

Search for this phrase: #define DEFAULT_AXIS_STEPS_PER_UNIT. This section is a critical part of the configuration process and allows you to set the number of steps per unit length. This is dependent on your timing pulleys, threaded rods, and extruder style. For this tutorial, we used: G2T timing belts and pulleys, an Mk8 extruder style, and an 8mm pitch thread screw. This means that the values we need to enter are: 78.74, 78.74, 2560, and 95.

Search for the phrase: #define EEPROM_SETTINGS. Make sure this is enabled. It allows you to change firmware settings without reloading the firmware.

Search for the phrase: #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en). This chooses the language of the user interface. Make sure it is set to your preferred language using the language.h file.

Search for the phrase: #define SDSUPPORT. Uncomment this so that you can use the SD card slot on the smart controller to print. This makes the printer a separate system from your computer.

Search for the phrase: #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER. Uncomment this so that you can use the smart controller used in this tutorial. If you decided to use another controller, search for it in the list and uncomment it instead.

Finally, upload your code and test it. Click the button to display the menu. Navigate to the Prepare menu. Navigate to move axis. Make sure you test every axis. The video below will show the proper result of testing.

Step 6: Finishing Touches

Clamp down the edges of the top plate. Make sure all your cables are correctly plugged in and dealt with.

Make sure all your axes are zeroed to their minimums.

Make sure all the components work. Tweak any settings as you see fit.


Step 7: Your First Print

Now, you’re ready for your first 3D print. Download the 3D printing slicing program Cura at this link:

Once it is downloaded, open the program and configure it for your printer. Choose custom FDM printer. Input the maximum build size: 105mm x 130mm x 80mm. Use a ruler to measure the other inputs. Make sure the Gcode flavor is RepRap Marlin.

Now, all you need is an SD card loaded with the STL file you want to print. I recommend you start by, in the spirit of RepRap, printing parts to improve this printer.


Click here to read Part 1: Build >

Click here to read Part 2: Code >