How to wire an arduino-based 3-axis CNC machine

Picture of How to wire an arduino-based 3-axis CNC machine

I've seen a number of tutorials about how to build the platform for a 3-axis CNC milling machine.  I have not seen anyone tackle the tricky subject of the electronics.

Here now is my attempt to do so.
Remove these adsRemove these ads by Signing Up

Step 1: Parts

You'll need:

- an arduino. I chose duemilanova. (depends on the board you get)
- 3 stepper motors.  I chose NEMA 17s . ($15/ea)
- 3 EasyDrivers from Sparkfun . ($15/ea)
- some Cat5 ($2?)
- a 12V power supply for the steppers ($5?)
- a soldering iron
- some electrical tape
- an optional female plug is not a bad idea (<$1)

TIP: Don't get a 6ft or 10ft Cat5 cable.  Buy your cat5 by the foot from any computer or electronics store. That stuff has one wire inside instead of lots of little fibers.  Little fibers are a huge pain to work with. 

Step 2: Wire the stepper motor to the EasyDriver

Picture of Wire the stepper motor to the EasyDriver
Now we'll wire up each of the EasyDrivers.

Remove some of the interior wire from the Cat5 and strip the ends.  For each servo you will need two normal pairs of white/colored and one oddball of a white and two colored.  In all, you'll have to strip 14 ends.

PCB soldering is easy, once you get used to it.  There are many other tutorials that cover the subjct.  Follow the image as indicated.  Your color combinations for the servo may be different.  I had to google for a long time to find this page with the color codes for my model.

TIP: "Do NOT connect or disconnect a motor while the driver is energized. This will cause permanent damage."  -- Sparkfun

Next we'll wire the power sources and the arduino.

1-40 of 169Next »
nreed42 years ago
Could you add a fourth stepper motor to pins 1 and 2? Could you also control a heatbed and an extruder (nichrome wire), because I am trying to build a 3d printer. Also how do you control the z-axis with only one motor.

Pins 1 and 2 are required for data input, you could only use them IF you set it up to just run the program you've already loaded, that didn't require any additional input. (in other words, no)
Running it with an uno, you really don't have enough output pins to control anything additional. If you built it with a mega, or something else, then you'd have additional data pins for controlling other things, but honestly it sounds like you should be using a ramp board anyways.
Z axis only requires 1 motor. I've seen some designs for extruder based printers that use 2 Z axis motors, but it's no more required than 2 motors on the X axis.

jmsiefer12 months ago

If you could answer a quick question for me, I would sincerely appreciate the help.

I'm making a homemade laser-cutter, and the problem I'm facing at the moment is how to trigger the laser ON instead of driving a stepper motor (the motor for the Z-Axis). Now, in your photo for Step 2: "Wired the Stepper Motor To the EasyDriver" you show "5 Out and Ground." Are these pins something I can control off and on? I'm using GRBL on the Arduino Uno, so I'm not sure exactly how I would write the GCode to do this.

Thank you so much!!!

Hi jmsiefer,

What you need is a relay module that will control the trigger of the laser.

nicken837 months ago

I'm building my own cnc router at this moment, using scrap materials. The constructrion of the hardware is allmost finished, en looks quite good! Time to start the programming en controlling of the steppermotors. I surely will use this handy tutorial. But what seems most unclear to me now is how i convert a drawing to g-code, and how do i get the g-code to the arduino?

Any help with this would be very appreciated!


Look up GRBL, it's a program you upload to the arduino to convert g-code to the motor drivers.

diyman10 months ago

Nice project!! I had a quick question. I was looking into getting the easy driver and 3 steppers for my cnc build but i'm not sure if my steppers will work with the easy drivers. all the steppers i have looked at so far are rated for 1.3A or so. the easy driver is only rated for 750mA. Will that stepper work for me or do i have to look for one rated under 750mA. I would appreciate it

Hi diyman!

I'm not the author, bus as I've been studying and searching on how to make these 3D moves, and from what I got, usually the stepper controllers I found were rated to a determined Current(A) on EACH coil. So as this steppers have 2 coils, I've read that it means it can handle a total of 1.5A. This one shield seems to be what I look for:

"4 H-Bridges: per bridge provides 0.6A (1.2A peak current) with thermal protection, can run motors on 4.5V to 36V DC"

I'm about to order it, but I'm still colecting some other hardware (and few cash ;) )

So I think that one you said works fine! I looked over it, but the L293D looks better and cheaper for me. Also I'm pretty sure I've read somewhere, that you can actualy kind of stack more L293D on each of the provided ones to increase Current! I won't need that, but it's a possibility.

For now I'll use it just to drive DVD Drive stepper motors, which I guess won't need more than 200/300mA, for testing purposes, to get it bigger later, with the same Electronics, but with Nema (17, probably)stepper motors driving a threaded rod.

I'm so eager to finally get to that big project! But I'm learning all by my self almost from 0, so it takes some time.

To the author, congratulations! There is actually a fault on guiding people on the electronics part of these machines, but you covered it really well! Thank you for that, and I hope to be able to return my knowledge back with a good tutorial and my good intention to exchange knowledge.

Best regards

agostina 20079 months ago

can this code interpret g code??

agostina 20079 months ago

can this code interpret g code??

smughal59 months ago

hello..i am having issues with the output.

this is what i have done so far:
1- downloaded hex file from
2- using Xloader, i have uploaded the hex file.
3- downloaded grbl controller.
Now when see the outputs from arduino uno pins, except pin 2,3,4 and 5, all pins are consistently high, while these 4 are consistently low.
i need to know where i am making a mistake.
The above mentioned steps are what exactly i have done not even a single thing different.
Please help…

pabloevaristo10 months ago

Hi, great job!.

I'm trying to use the adafruit motorshield as stepper controller but I don't know the pin configuration for grbl files.

Do you have any sketch about this?

Thanks a lot

Richley1 year ago

Will this work with Arduino UNO or will it only work with Arduino Duemilanova ?

Is it possible to connect 3 stepper drivers with ONE EasyDriver ? ( i doubt it's possible, but wants to know about the possibility for that )

Yes, this will work with all flavors of Arduino.

Short answer, Yes you can connect all 3 to the same easydriver but they will all turn the same.

Long Answer: Stepper motors, unlike "regular" DC motors, have 2 sets of coils inside. To turn a stepper, you need to alternately turn these coils on and off, which is what the Easy-driver does. So, if you want to control 3 stepper motors... you need 3 drivers.

another question here, can I connect one Raspberry Pi, directly to 3 Stepper Motor, and control all 3 of them to turn different direction/speed ?
or must I connect a Raspberry Pi -> 3 EasyDriver -> 3 Stepper Motor

jatinbatra1 year ago
Can I run 4 steppers with Arduino and stepper drivers ?
Why do you have to use easy drivers , when you could just buy cheap ICs like L293Ds and ULN2003/4 to drive your steppers?

Each driver needs 2 digital lines: Step and Direction. So, you can run as many drivers as your arduino has pins for.

I'm still new to the Arduino and can't answer your 4-axis question, but I am currently working on building a CNC using the L298 driver. To use the L298 "like" an EasyDriver, you also need the L297 controller (or equivalent) and some other components. The L293D is only a driver (handles the voltage and current) and requires a controller just like the L298. The ULN2003/4 is a DARLINGTON ARRAY and is not designed for the current desires of a stepper.






mkulesza1 year ago

The Lord's great imaged motor control and stepper motors rather for the help of the driver.

I just have one question .... Can I control L298 driver, front using the Arduino for the help mach3

I am currently working on building a CNC using the L298 driver. To use it "like" an EasyDriver, you also need the L297 controller (or equivalent) and some other components (look up PDF).

Hi. Are you using the grbl code in Arduino for the CNC?
Or have you made one your self?
What prog are you using for designing and g-code?

jmsiefer1 year ago
I'm just getting into Arduino, so I do apologize for the question, however is it possible to use an Arduino Uno for this project?
aggrav8d (author)  jmsiefer1 year ago
Heyy, It's not possible for me to get 4 easy drivers to use it with 3D printer , rather I would like to use my own drivers, I 'm thinking to use L293D or simple H bridges to run my Bipolar stepper ( 4 wires) , how can I make it run , I have seen number of programs and software like grbl for easy drivers ,Adafruit motor shield V1 and V2 , grbl shield but not with H-bridges , so the issue is pretty common for many people as well.
I tried two out of three motors , uploaded grbl to Arduino and sent Gcodes from Universal Gcode sender , only one of my motor seem to work (however very slowly nad an irritating "buzzzzzzzz" like noise is coming out of it). I tried some variations with steps for different axis and I could see it move with 10 steps/mm.
I don't know what to do.
Can't you make easy drivers or motor shield or grbl shield on your own ?
Also I need a 4 axis driver as I would be using it for my 3d printer.
Thanks, any help would be appreciated.
gakes1 year ago
Thanks for the info...Can I wire up 3 different stepper motors to work on my cnc or do they have to be the same? I was wondering if I could adjust the movements on each stepper separately
aggrav8d (author)  gakes1 year ago
You can. It's a lot easier to use three of the same thing - less variation means less debugging.
i wanted to make my project, cnc milling, wireless. so i need inputs on how i would be able to send gcode generated in eagleCAD wirelessly?? and what all necessary changes i would need to make in electronics section of the project. kindly help.
aggrav8d (author)  write2upadhyay1 year ago
Sorry, I can't help you with this. I have almost zero experience with wireless.
thanks for your response. i had some input that we can send the gcode generated via a serial-to-bluetooth converted and can recieve the code in reciever blutooth which we will interface on controller, in place of serial port. i was just wondering whether it will work or not
aggrav8d (author)  write2upadhyay1 year ago
I don't see a problem as long as the connection doesn't drop. Wifi, cable, bluetooth... it's all the same.
yes, you right. i am doing my final year project and our guide is expecting us to do some out-of-box someone in our group suggested making it wireless, and now we are juggling to get the idea implemented..
Tony321 year ago
Could these NEMA17's be enough to have a dremel on it and cut wood? Or are they too weak? Nice tutorial!
Very well said. I'm a noob and need serious help. If you don't mind, I'll compile a list on the programming side of things since I only plan to engrave my business name and phone number on keys. Thanks a bunch. Btw, I love this tutorial.
qw6231 year ago
I'll hopefully be able to release a schematic/EAGLE file for a complete self containing driver using an Arduino, 3 easy drivers along with maybe an Ethernet shield. Thanks for the instructions, now I have something to go off of!
You, sir, are a bada$$.

Thanks. I still don't understand how you program the Arduino to understand G code. Could you please go into a little more detail? Or post another Instructable?
Sorry I seem so ignorant and lost. It's because I am. I'm trying to learn this as a 65 year old guy who grew up in a world where things like Arduinos were beyond our wildest imaginings.
aggrav8d (author)  junkrigsailor2 years ago
try or . Both are robots that listen to gcode from the serial connection and then do...things.
How does the Arduino know which way and which motor from the G code via USB? Does it just natively "speak" G code?
aggrav8d (author)  junkrigsailor2 years ago
I program my arduino to understand gcode, then figure out which motor to move (and which direction) based on the gcode instructions.
A good example of a system I built with two motors is my polargraph drawing robot, the Makelangelo:
Lee_Smith2 years ago
is there any reason why the delay has to increase between rising edges? would it be fine if you left it at 160? also how does i<3400 come out to 4000 microsteps?

Sorry for all the questions but i'm very fascinated in this for my arduino. Also I am in the process control and automation field professionally and for max torque out of stepper motors it is best to keep them running at lower speeds. Depending on your power supply voltage just about anything over 10 revs/second starting dropping torque considerably.
1-40 of 169Next »