Hardware
| Item | Description |
|---|---|
| Arduino Nano IOT 33 | A compact and powerful microcontroller board for IoT projects. |
| Stepper Motor (Nema 17) | Link |
| Stepper Motor Driver (TMC2209) | Link Many a times the numbering is not correct on |
| Breadboard | A platform for building electronic circuits without soldering. |
| Connecting wires | Wires used to connect components together on the breadboard. |
| External Power supply | A power source needed to drive the stepper motor and ensure proper operation. I have used 12V/30A SMPS which works good. Stepper motor can take anywhere between 5.5V to 24V. Current should be no where close to 1A. You can use battery as well 4X1.5V batteries in series or 9V battery. |
Connection Diagram

Code (Arduino IDE)
/*
Author: Aadi Yemul
Date: September 15, 2025
Location: Redmond, WA
Purpose:
Demonstrate interfacing the TMC2209 stepper driver with an Arduino UNO.
The code moves a NEMA 17 (or similar stepper motor) forward and backward
by generating step pulses on the STEP pin, while controlling the direction
with the DIR pin. The EN pin is used to enable/disable the driver.
*/
// ---------------- Pin Definitions ----------------
#define EN_PIN 8 // Enable pin: LOW = driver enabled, HIGH = driver disabled
#define STEP_PIN 9 // Step pin: motor moves one step on each rising edge
#define DIR_PIN 10 // Direction pin: sets rotation direction (LOW = one way, HIGH = opposite)
// ---------------- Motion Parameters ----------------
int noOfSteps = 500; // Number of steps to move in each direction
int microSecondsDelay = 1000; // Delay between step pulses (controls speed)
// ---------------- Setup ----------------
void setup() {
// Configure pins as outputs
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
// Initialize driver state
digitalWrite(EN_PIN, LOW); // Enable the driver (active LOW)
digitalWrite(DIR_PIN, LOW); // Set initial direction
}
// ---------------- Main Loop ----------------
void loop() {
// Rotate motor in one direction
digitalWrite(DIR_PIN, LOW); // Set direction to LOW
moveSteps(noOfSteps);
// Rotate motor in the opposite direction
digitalWrite(DIR_PIN, HIGH); // Set direction to HIGH
moveSteps(noOfSteps);
}
// ---------------- Function Definitions ----------------
/*
moveSteps(steps):
Generates 'steps' number of step pulses on STEP_PIN.
Each step pulse consists of a HIGH followed by a LOW state,
with a configurable delay between pulses.
*/
void moveSteps(int steps) {
for (int i = 0; i < steps; i++) {
digitalWrite(STEP_PIN, HIGH); // Rising edge: triggers step
delayMicroseconds(microSecondsDelay);
digitalWrite(STEP_PIN, LOW); // Falling edge: completes step
delayMicroseconds(microSecondsDelay);
}
}
Nema 17 Stepper Motor Specifications
Electrical Specification
Manufacturer Part Number: 17HE15-1504S
Motor Type: Bipolar Stepper
Step Angle: 1.8 deg
Holding Torque: 42Ncm (59.49oz.in)
Rated Current/phase: 1.50A
Phase Resistance: 2.3 ohms
Inductance: 4.00mH ± 20% (1KHz)
Physical Specification
Frame Size: 42 x 42mm
Body Length: 38mm
Shaft Diameter: Φ5mm
Shaft Length: 23.5mm
D-cut Length: 20mm
Number of Leads: 4
Lead Length: 1000mm
Weight: 280g
Connection
A+: Black, A-: Blue, B+: Green, B-: Red
TMC2209
| Pin | Function |
|---|---|
| . | Power Supply |
| GND | Ground |
| VM | Motor Supply Voltage (5.5-28V) |
| VIO | Logic Supply Voltage (3.3-5V) |
| . | Motor Outputs |
| M1A | Motor Coil 1 |
| M1B | Motor Coil 1 |
| M2A | Motor Coil 2 |
| M2B | Motor Coil 2 |
| . | Control Inputs |
| STEP | Step-Signal Input |
| DIR | Direction-Signal Input |
| EN | Enable Motor Outputs (GND=on, VIO=off) |
| . | Configuration |
| MS1 | Step-Configuration or Slave-Address on UART, pd |
| MS2 | Step-Configuration or Slave-Address on UART, pd |
| SPREAD | Chopper, pd (GND=stealthChop, VIO=spreadCycle) |
| PDN_UART | UART and Auto Power Down Control, pd (GND=on, VIO=off) |
| DIAG | Diagnostics Output (VIO=error) |
| INDEX | Index Output (one pulse per each four fullsteps) |
| VREF | Analog Reference Voltage |
pd – pin with pull-down resistor (to GND)