This project involves controlling the rotational speed of a NEMA 17 stepper motor using an A4988 stepper motor driver and an Arduino Nano. A 10kΩ potentiometer adjusts the motor’s speed by varying the delay between step pulses sent to the A4988 driver. The motor rotates in one direction, with speed ranging from slow to fast based on the potentiometer’s position. The system is powered by a 12V DC adapter, suitable for the motor and driver. The project demonstrates precise motor control, useful for applications requiring variable-speed rotation, such as robotics, CNC machines, or automation systems. The provided code has been modified to address the motor vibration issue at high speeds by setting a safer speed range (500–2000µs step delay)
Stepper motors are widely used in applications requiring precise positioning and speed control, such as 3D printers, CNC machines, and robotic arms. The NEMA 17 stepper motor, with a holding torque of 4 kg·cm (approximately 0.4 N·m), is a common choice for small to medium-sized projects due to its compact size and sufficient power. The A4988 driver simplifies control by managing the motor’s coil currents and supporting microstepping for smoother operation. In this project, an Arduino Nano reads the analog input from a 10kΩ potentiometer to adjust the step pulse frequency, thereby controlling the motor’s speed. The system is designed to be simple, cost-effective, and adaptable for educational and practical applications.
Parts Required
Component | Details | Quantity |
---|---|---|
Arduino Nano | Microcontroller (ATmega328P, 5V, 16 MHz, 14 digital I/O, 8 analog inputs) | 1 |
NEMA 17 Stepper Motor | 4 kg·cm (0.4 N·m) torque, 1.8°/step (200 steps/rev), typically 1.5–2A, 12V | 1 |
A4988 Stepper Driver | Microstepping driver, up to 2A per phase, 8–35V motor voltage | 1 |
10kΩ Potentiometer | Linear taper, for speed control (0–5V analog output) | 1 |
12V DC Power Adapter | 12V, ≥2A (to power motor via A4988; ensure sufficient current) | 1 |
Buck Converter | Steps 12V to 5V, ≥1A (for Arduino and logic if needed) | 1 |
Capacitor | 100µF, 25V (for A4988 VMOT stability in power input) 2 unit - 10µF for Voltage regulations | 3 |
Breadboard | For prototyping connections | 1 |
Jumper Wires | Male-to-male, various lengths (for connections) | ~20 |
Multimeter (optional) | For setting A4988 VREF and debugging | 1 |
Notes:
- NEMA 17: Verify motor’s current rating (e.g., 1.5A) and coil pairs (typically 4 wires: A1-A2, B1-B2).
- A4988: Includes a small potentiometer for current limiting; ensure a heatsink for currents >1A.
- Power Adapter: Must supply enough current (e.g., 2A for motor + 0.5A for Arduino/logic).
- Buck Converter: Optional if powering Arduino via USB; required if using 12V VIN for Arduino.
Circuit Diagram
12V Adapter (+) ---- A4988 VMOT ---- Buck Converter VIN 12V Adapter (-) ---- Common GND
Buck Converter (5V) ---- Arduino 5V (or VIN if bypassing onboard regulator) ---- Potentiometer (5V end) ---- A4988 VDD Buck Converter (GND) ---- Common GND
Arduino Nano A4988 D5 ---- STEP D4 ---- DIR 5V ---- VDD GND ---- GND
A4988 Stepper Motor 1A, 1B ---- Coil 1 (e.g., Red-Blue) 2A, 2B ---- Coil 2 (e.g., Green-Black) VMOT ---- 12V Adapter + GND ---- 12V Adapter - (with 100µF capacitor across VMOT-GND)
Arduino Nano Potentiometer (10kΩ) A0 ---- Wiper 5V ---- One end (via buck converter or Arduino 5V) GND ---- Other end
Notes:
- Coil Wiring: Check motor datasheet for coil pairs (e.g., A1-A2, B1-B2). Incorrect wiring causes vibration.
- Capacitor: 100µF across A4988 VMOT and GND prevents voltage spikes.
- Grounding: All GNDs (Arduino, A4988, adapter, buck converter) must be connected to a common point.
Video Link: - Click Here For Video
How To control Stepper Motor Speed with Potentiometer DIY Project by WTC Zone simple Circuit: -
Arduino IDE Program
Code for Clap to Light Up LED light Using Sound Sensor DIY Project by WTC Zone
The original code had a step delay range of 0–10000µs, which is problematic (0µs is invalid and causes issues). The modified code below uses a safer range (500–2000µs) to prevent vibration at high speeds, adds the ENABLE pin for reliability, and includes Serial debugging.
//https://www.youtube.com/@wtczone
// Pin definitionsconst int stepPin = 5; // STEP pinconst int dirPin = 4; // DIR pinconst int potPin = A0; // Potentiometer pin
void setup() { // Set pins as outputs pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); // Set initial direction (HIGH = one direction, LOW = opposite) digitalWrite(dirPin, HIGH);}
void loop() { // Read potentiometer value (0-1023) int potValue = analogRead(potPin); // Stop motor if pot is near 0 if (potValue < 50) { return; // Skip the rest of the loop → motor stops }
// Map potentiometer value to delay (faster = lower delay) int stepDelay = map(potValue, 50, 1023, 5000, 50); // Min speed: 2000µs, Max speed: 500µs // Generate a step pulse digitalWrite(stepPin, HIGH); delayMicroseconds(10); // Short pulse digitalWrite(stepPin, LOW); // Delay between steps (controls speed) delayMicroseconds(stepDelay);}
Share, Support, and Subscribe!!! 1. PRO KAM EXPLAINED 2. Knowledge KAM 3. PRO KAM Follow us on 1. Facebook 2. Instagram 3. Pinterest 4. Blogspot 5 Twitter If you have any other ideas to make me design, you can describe them in the comment section and if I can, I will make a designing video on it. So I am waiting #prokam #wtc #Arduino #ideas #projects #diy #how #to #ArduinoProjects #UltrasonicSensor #HeightMeasurement #TechDIY #WeTechCreators #wtczo
0 Comments