Creating an automated CNC machine using Arduino is one of the best engineering projects for students in Pakistan. A CNC (Computer Numerical Control) machine automates cutting, drilling or milling using programmed commands — you draw a design on the computer, and the machine cuts it out. With Arduino-based control it becomes cost-effective and accessible for student projects and industrial prototypes. This guide explains every detail, from circuit design to component setup, using GRBL firmware and a CNC Shield.

When you load a design into the software, the design is converted into G-code — simple text commands like "move to X20 Y20" or "cut down 1 mm". The G-code is sent to the Arduino over USB. GRBL firmware running on the Arduino reads the G-code and generates the step and direction pulses for the motors. The CNC Shield does not interpret commands — it is a passive board that only routes power and signals: it holds the stepper drivers, connects them to the Arduino pins, and feeds 12V to the motors. Each motor turns a lead screw, shifting the tool head precisely. Limit switches stop the tool safely at the defined boundary.
This project suits mechanical, electrical and electronics engineering students looking for practical automation experience.
| Component | Price / link |
|---|---|
| Arduino UNO R3 DIP | Arduino UNO R3 DIP ATmega328P with USB Cable — Rs 1,200 |
| CNC Shield V3 | Arduino CNC Shield V3 Compatible with A4988 and DRV8825 Drivers — Rs 350 |
| NEMA17 stepper motor × 3 (X, Y, Z axes) | Branded NEMA 17 Stepper Motor — Rs 670 each |
| 12V 2A AC/DC adapter | 12V 2A AC/DC Adapter — Rs 275 |
| A4988 or DRV8825 stepper driver × 3 | No QKZEE listing — available at the Hall Road shop on request |
| Limit switch × 6 (two per axis) | No QKZEE listing — available at the Hall Road shop on request |
| Frame, lead screws and linear rails | No QKZEE listing — build from aluminium extrusion or a kit |
| Small rotary tool / 775 DC motor (spindle) | No QKZEE listing — any small rotary tool works as the cutting head |
| NodeMCU ESP8266 (optional, for the IoT version) | NodeMCU ESP8266 CH340 WiFi Board — Rs 590 |
Use the Arduino UNO (or Nano) — standard GRBL does not run on the Arduino Mega. The small 28BYJ-48 stepper is too weak for a CNC; use NEMA17 motors.
Plug the CNC Shield V3 directly onto the Arduino UNO — it sits on top of the UNO's pins. No jumper wires are needed between the two boards.
Insert one A4988 or DRV8825 driver into each of the X, Y and Z slots on the shield. Check the orientation first: the driver's EN (enable) pin must line up with the shield's EN marking. A driver inserted backwards burns instantly. Fit the three microstepping jumpers under each driver (all three jumped = 1/16 microstepping on an A4988, 1/32 on a DRV8825).
Connect each NEMA17 motor to its 4-pin port on the shield: X motor to the X port, Y to Y, Z to Z. If a motor runs backwards later, swap one coil pair (or fix it in software with $3 — see GRBL Settings below).
Connect the 12V adapter to the shield's screw terminals (12–36V input). The 12V goes to the shield for the motors only — the Arduino is powered separately through its USB cable. Do not feed 12V into the Arduino's 5V pin.
Fit one limit switch at each end of each axis (6 total). Wire them to the shield's limit pins — see the GRBL pin table below. GRBL stops the machine when a switch is hit, so the tool cannot run past the end of an axis.
Connect the Arduino to your computer via USB. This carries the G-code from Universal G-code Sender (UGS) to the GRBL firmware.
| Signal | Arduino pin |
|---|---|
| X step | D2 |
| Y step | D3 |
| Z step | D4 |
| X direction | D5 |
| Y direction | D6 |
| Z direction | D7 |
| X limit | D9 |
| Y limit | D10 |
| Z limit | D11 |
| Spindle enable | D12 |
| Spindle direction | D13 |
| Probe | A5 |
| Feed hold | A1 |
| Cycle start | A2 |
| Reset | A0 |
GRBL is firmware, not a sketch you write — you flash it onto the UNO once, and from then on the UNO only understands G-code. (If you have never uploaded a sketch before, see our How to Upload Code in Arduino UNO guide first — the upload steps are the same.)
grbl-master.zip file).Grbl 1.1h ['$' for help]. If it prints garbage, the baud rate is wrong — set it to 115200.$$ to see the GRBL settings.| Setting | What it means |
|---|---|
$100, $101, $102 | Steps per mm for X, Y, Z — calibrate these (see Testing) |
$110, $111, $112 | Maximum speed in mm/min for X, Y, Z |
$120, $121, $122 | Acceleration in mm/s² for X, Y, Z |
$130, $131, $132 | Maximum travel in mm for X, Y, Z |
$3 | Direction invert — flips an axis that runs backwards |
$22 | Homing enable (1 = home the machine on $H) |
$$ | Show all settings |
This cuts a 20 × 20 mm square, 2 mm deep, in two passes. Run it in UGS on a piece of foam first — never test a new machine on hard material.
G21 ; millimetres
G90 ; absolute positioning
G0 Z5 ; lift the tool to 5 mm
G0 X0 Y0 ; move to the start corner
G1 Z-1 F100 ; plunge 1 mm down
G1 X20 F300 ; cut along X
G1 Y20 ; cut along Y
G1 X0 ; back along X
G1 Y0 ; back along Y
G1 Z-2 F100 ; second pass, 2 mm deep
G1 X20 F300
G1 Y20
G1 X0
G1 Y0
G0 Z5 ; lift the tool
M30 ; end of programG21 sets millimetres and G90 sets absolute positioning — every coordinate is measured from the same zero point.G0 moves fast without cutting (the tool is lifted to Z5 first so it does not drag across the material).G1 moves while cutting, at the feed rate after F (F300 = 300 mm/min; the plunge uses a slower F100).M30 ends the program and resets to the start.Build a rigid frame from aluminium extrusion or plywood, with lead screws and linear rails for the X, Y and Z axes. A wobbly frame gives wobbly cuts — rigidity matters more than size.
Mount one NEMA17 motor per axis, coupled to its lead screw, and the rotary tool as the spindle on the Z axis. Check each axis slides freely by hand before powering anything.
Stack the shield, fit the drivers (orientation first), connect the motors, the 12V supply and the limit switches as in the tables above. Set each driver's current (Vref) before the first run — for a typical 1.5 A NEMA17 with 0.1 Ω sense resistors, Vref ≈ 1.2 V on an A4988. Check your driver's datasheet; never run a driver with no motor connected.
Flash GRBL as above, connect UGS at 115200 baud, and confirm the Grbl 1.1h message. Jog each axis from UGS and check it moves the right way and the right distance.
Command a 10 mm move and measure the real movement with a ruler. If it moved 8 mm, raise $100 (for X) by 10/8. Repeat until a commanded 10 mm is a real 10 mm on all three axes. This one step decides whether your parts come out the right size.
Run the sample G-code on foam or soft wood. Only when the square measures 20 × 20 mm should you cut harder material.
$H — the machine should move each axis to its limit switch and stop. If it keeps pushing, a limit switch is wired wrong.$100–$102).$3 (direction invert) for that axis — do not rewire the motor.$100–$102) are wrong — calibrate as in Step 5 above.$21 (hard limits) is set to 1.A CNC machine has moving parts and a spinning cutter — treat it with respect. Keep hands clear of the tool while it runs. Wear eye protection. Fit an emergency-stop switch in the 12V line. Never leave a running machine unattended. This is a student model, not an industrial machine — do not cut metal with it.
Many students in Pakistan use this system for their FYPs, combining mechanical design, electronics and software programming.
To create an advanced version, integrate:
These upgrades make your CNC project part of the next generation of industrial automation.
The Arduino UNO, CNC Shield V3, NEMA17 motors, 12V adapter and NodeMCU are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links above. A4988/DRV8825 drivers, limit switches, the frame and lead screws, and the rotary tool spindle are available at the Hall Road shop on request.
If GRBL does not respond, or a motor does not move, message us — tell us what the Serial Monitor shows and which step you are on, and we will help you find the fault.
Chat on WhatsApp Watch on YouTube
Can I use an Arduino Mega for GRBL?
No — standard GRBL runs on the ATmega328P (UNO/Nano) only. Use the UNO. The Mega is not supported.
Do I need the CNC Shield, or can I wire the drivers directly?
You can wire drivers directly to the Arduino, but the shield makes it far easier: it holds the drivers, routes the step/dir pins, and takes the 12V supply in one place. For a first build, use the shield.
Why does my driver burn on first power-up?
It was inserted backwards. The EN pin must line up with the shield's EN marking. Always check orientation before powering the shield.
What is Vref and why does it matter?
Vref sets the driver's motor current. Too low and the motor stalls; too high and the motor and driver overheat. Set it from your motor's rated current and your driver's datasheet before the first run.
Can this CNC cut metal?
No — this is a student model for foam, soft wood, plastic and PCB engraving. Cutting metal needs a rigid industrial machine and a proper spindle.
What software makes the G-code?
For 2D shapes, Inkscape with a G-code extension; for 3D parts, Fusion 360 or FreeCAD. Both export the .nc/.gcode files that UGS loads.
An automated CNC machine using Arduino is the perfect engineering project blending automation, mechanical control and IoT innovation. By following these steps — wire the shield and drivers correctly, flash GRBL, calibrate the steps per millimetre, and test on foam first — students in Pakistan can build a professional-grade system for final year projects or industrial automation research.