Controlling NEMA 17 Stepper Motor With Arduino and A4988 Stepper Driver Module
Controlling NEMA 17 Stepper Motor With Arduino and A4988 Stepper Driver Module
COM/ARDUINO-PROJECTS)
"
Controlling NEMA 17 Stepper Motor with Arduino and A4988
Stepper Driver Module (/microcontroller-projects/controlling-
nema-17-stepper-motor-with-arduino-and-a4988-stepper-driver-
module)
By (page_author.html)Ashish Choudhary (/users/ashish-choudhary) ! Sep 10, 2019 0
Controlling NEMA 17 Stepper Motor with Arduino and Potentiometer
In this tutorial, we are going to control NEMA17 stepper motor using Arduino Uno and A4988 stepper driver module. Nema17 stepper motor
has higher torque and higher operating voltage than 28-BYJ48. Here a potentiometer will also be attached to control the direction of stepper
motor.
Component Required
Arduino UNO
NEMA17 Stepper Motor
A4988 Stepper Driver Module
47 µf Capacitor
Potentiometer
* Disclaimer
As you can see that this motor has a Unipolar six-wire arrangement. These wire are connected in two split windings. Black, Yellow, Green wires
are part of ^rst winding where Black is center tap, and Yellow and Green are coil end while Red, White, and Blue is part of a second winding, in
which White is center tap and Red and Blue are coil end wires. Normally center tap wires left disconnected.
Steps Per Revolution for a particular stepper motor is calculated using the step angle of that stepper motor. So in the case, NEMA 17 step angle
is 1.8 deg.
SpeciDcations of NEMA17
Also check various stepper motor related projects (https://circuitdigest.com/tags/stepper-motor) here, which not only incudes basic interfacing
with various microcontrollers but also have robotics projects (https://circuitdigest.com/robotics-projects) which involves stepper motor.
A stepper driver module controls the working of a stepper motor. Stepper drivers send the current to stepper motor through various phases.
The A4988 Nema 17 stepper driver is a microstepping driver module that is used to control bipolar stepper motors. This driver module has a
built-in translator that means that we can control the stepper motor using very few pins from our controller.
Using this Nema 17 motor driver module, we can control stepper motor by using only two pins, i.e., STEP and DIRECTION. STEP pin is used to
control the steps while DIRECTION pin is used to control the direction of the motor. A4988 driver module provides Dve different step
resolutions: full-step, haft-step, quarter-step, eight-step, and sixteenth-step. You can select the different step resolutions using the resolution
selector pins ((MS1, MS2, and MS3). The truth table for these pins is given below:
MS1 MS2 MS3 Microstep Resolution
SpeciDcations of A4988
Microstep resolution: Full step, ½ step, ¼ step, 1/8 and 1/16 step
Circuit Diagram
(/fullimage?
i=circuitdiagram_mic/Circuit-Diagram-for-Controlling-NEMA17-Stepper-Motor-with-Arduino.png)
SPONSORED SEARCHES
A4988 Arduino Code
If you turn the potentiometer clockwise, then stepper will rotate clockwise, and if you turn potentiometer anticlockwise, then it will rotate
anticlockwise. A 47 µf capacitor is used to protect the board from voltage spikes. MS1, MS2, and MS3 pins left disconnected, that means the
driver will operate in full-step mode.
3 VDD 5V of Arduino
Code Explanation
Complete code with working video control Nema 17 with Arduino is given at the end of this tutorial, here we are explaining the complete
program to understand the working of the project.
First of all, add the stepper motor library to your Arduino IDE. You can download the stepper motor library from here
(https://github.com/arduino-libraries/Stepper).
After that de^ne the no of steps for the NEMA 17. As we calculated, the no. of steps per revolution for NEMA 17 is 200.
#include <Stepper.h>
#define STEPS 200
After that, specify the pins to which driver module is connected and de^ne the motor interface type as Type1 because the motor is connected
through the driver module.
Next set the speed for stepper motor using stepper.setSpeed function. Maximum motor speed for NEMA 17 is 4688 RPM but if we run it faster
than 1000 RPM torque falls of quickly.
void setup() {
stepper.setSpeed(1000);
Now in the main loop, we will read the potentiometer value from A0 pin. In this loop, there are two functions one is potVal, and the other is Pval.
If the current value, i.e., potVal is higher than the previous value, i.e., Pval than it will move ten steps in the clockwise direction and if the current
value is less than previous value than it will move ten steps in the counter-clockwise direction.
potVal = map(analogRead(A0),0,1024,0,500);
if (potVal>Pval)
stepper.step(10);
if (potVal<Pval)
stepper.step(-10);
Pval = potVal;
Now connect the Arduino with your laptop and upload the code into your Arduino UNO board using Arduino IDE, select the Board and port no
and then click on the upload button.
Now you can control the direction of Nema17 stepper motor using the potentiometer. The complete working of the project is shown in the
video below. If you have any doubts regarding this project, post them in the comment section below.
Code
#include <Stepper.h>
// De^ne stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver
Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver
#de^ne motorInterfaceType 1
int Pval = 0;
int potVal = 0;
void setup() {
stepper.setSpeed(1000);
void loop() {
potVal = map(analogRead(A0),0,1024,0,500);
if (potVal>Pval)
stepper.step(10);
if (potVal<Pval)
stepper.step(-10);
Pval = potVal;
Video
RECOMMENDED POSTS
(http://bit.ly/2qhkOds )
(http://bit.ly/2NLAL4l )
(http://bit.ly/37efx6G )
(http://bit.ly/2THbcFm )
(http://bit.ly/30G58OA )
(http://bit.ly/36iL2vl )
(http://bit.ly/3aIFQEt )
Email Address *
Name
Country
United States of America
Subscribe
RELATED CONTENT
(/microcontroller-projects/adustable-electronic-dc-load-using-arduino)
(/microcontroller-projects/arduino-smart-restaurant-menu-ordering-menu-ordering-system)
(/microcontroller-proejcts/arduino-buzz-wire-game)
(/microcontroller-projects/ac-fan-speed-control-using-arduino-and-triac)
(/microcontroller-projects/arduino-walkie-talkie-using-nrf24l01)
(/microcontroller-projects/arduino-rc-car-using-bldc-motors-and-nrf24l01-rf-module)
Fastest Arduino RC Car using Coreless DC Motors and nRF24L01 RF module (/microcontroller-projects/arduino-rc-car-using-bldc-motors-
and-nrf24l01-rf-module)
(/news/arduino-releases-new-ide-1811-with-improved-mac-os-support-and-reduced-build-time)
Arduino Releases new IDE 1.8.11 with Improved MAC OS Support and Reduced Build Time (/news/arduino-releases-new-ide-1811-with-
improved-mac-os-support-and-reduced-build-time)
(/microcontroller-projects/arduino-based-water-wow-sensor)
Measuring water Flow Rate and Volume using Arduino and Flow Sensor (/microcontroller-projects/arduino-based-water-wow-sensor)
# PREVIOUS POST
DIY Pick and Place Robotic Arm using ARM7-LPC2148 ARM Microcontroller (https://circuitdigest.com/microcontroller-projects/diy-
robotic-arm-using-lpc2148-microcontroller)
NEXT POST $
Arduino Sleep Modes and How to use them to Save the Power (https://circuitdigest.com/microcontroller-projects/arduino-sleep-
modes-and-how-to-use-them-to-reduce-power-consumption)
COMMENTS
(http://bit.ly/2PuO9KS
)
TI TPS7A24 Low-Dropout Linear Voltage Regulator (http://bit.ly/3aeOQ2K )
Supports a 2.4V to 18V input voltage range with ultra-low quiescent current (IQ).
(http://bit.ly/3aeOQ2K
)
Panasonic SVPT Conductive Polymer Aluminum Solid Capacitors (http://bit.ly/2T78x7e )
Feature low ESR range from 15–24mΩ and cover a capacitance range of 100µF to 5600µF.
(http://bit.ly/2T78x7e
)
ON Semiconductor NxHL080N120SC1 N-Ch SiC MOSFETs (http://bit.ly/2Tg70dC )
1200V, 80mΩ MOSFETs that provide superior switching performance and high reliability.
(http://bit.ly/2Tg70dC
)
Microchip VC-801 CMOS Crystal Oscillators (XO) (http://bit.ly/3acX9MA )
Quartz stabilized square wave generator with a CMOS output.
(http://bit.ly/3acX9MA
)
MAX17634x Synchronous Step-Down DC-DC Converter (http://bit.ly/2wUVgpE )
Comes with integrated MOSFETs and operates over an input-voltage range of 4.5V to 36V.
(http://bit.ly/2wUVgpE
)
Coilcraft 1812CAN Common Mode Choke Inductors (http://bit.ly/32xaTiC )
Designed for CAN or CAN FD in automotive or general industrial automation applications.
(http://bit.ly/32xaTiC
)
Analog Devices ADPD188BI Integrated Optical Module (http://bit.ly/2PxuOJ5 )
Complete photometric systems for smoke detection using optical dual-wavelength technology.
(http://bit.ly/2PxuOJ5
)
NEWS ARTICLES PROJECTS
(/news/new-
ultra-
compact-5-
15w-ac-dc-
converters-
from-
mornsun)
Low Power Dual Channel Digital Isolators to Protect Electronic Subsystems from Noise and High Voltages (/news/low-power-dual-
channel-digital-isolators-to-protect-electronic-subsystems-from-noise-and-high-voltages)
(/news/low-
power-dual-
channel-
digital-
isolators-to-
protect-
electronic-
subsystems-
from-noise-
and-high-
voltages)
Low Pro^le, 4.3V to 65V non-isolated SMD DC/DC Converter with 0.5A Output Current (/news/low-pro^le-43v-65v-non-isolated-smd-
dcdc-converter-with-05a-output-current)
(/news/low-
pro^le-43v-
65v-non-
isolated-smd-
dcdc-
converter-
with-05a-
output-
current)
High Ezciency 18V, 6A Synchronous DC-DC Buck Converter with integrated MOSFET (/news/high-ezciency-18v-6a-synchronous-dc-dc-
buck-converter-with-integrated-mosfet)
(/news/high-
ezciency-
18v-6a-
synchronous-
dc-dc-buck-
converter-
with-
integrated-
mosfet)
LiDAR ICs by Maxim Offer More Than 2x Higher Bandwidth for Faster Self-Driving Cars (/news/lidar-ics-by-maxim-offer-more-than-2x-
higher-bandwidth-for-faster-self-driving-cars)
(/news/lidar-
ics-by-maxim-
offer-more-
than-2x-
higher-
bandwidth-
for-faster-self-
driving-cars)
FEATURED
PRODUCTS
(http://bit.ly/32Ep05L
)
Kick-start your Wi-Fi development (http://bit.ly/38bOubZ )
Ramp to production in as little as 6 months with the newest SimpleLink™ Wi-Fi® LaunchPad™ development kits.
(http://bit.ly/38bOubZ
)
The CLB can customize what you need within your design. (http://bit.ly/2I4knbM )
Integrate custom logic and augment peripheral capability with C2000™ MCUs con^gurable logic block (CLB) peripheral.
(http://bit.ly/2I4knbM
)
The next-generation TI mmWave sensor for ADAS (http://bit.ly/2vw0Wpw )
Solve long-range ADAS challenges with the second-generation AWR2243.
(http://bit.ly/2vw0Wpw
)
Connect with us on social media and stay updated with latest news, articles and projects!
(https://www.facebook.com/circuitdigest/)
(https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw)
(https://www.instagram.com/circuit_digest/)
(https://www.pinterest.com/circuitdigest/)
digest/)
CATEGORIES
POPULAR
NEWSLETTER
Subscribe
Privacy Policy (http://circuitdigest.com/privacy-policy) | Cookie Policy (https://circuitdigest.com/cookie-policy) | Terms of Use (https://circuitdigest.com/terms-of-use) | Contact Us
(http://circuitdigest.com/contact) | Advertise (http://circuitdigest.com/advertise)