Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
1 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
2 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
A4988 stepper motor driver ([Link]
([Link]
/2MJybwI)
NEMA 17 stepper motor
([Link]
([Link]
PID-324-Stepper-motor/dp/B01N30ISYC Stepper-motor/dp/B01N30ISYC
/ref=as_li_ss_tl?keywords=nema+17& /ref=as_li_ss_tl?keywords=nema+17&
qid=1575555491&s=electronics&sr=1-2& qid=1575555491&s=electronics&sr=1-2&
linkCode=ll1&tag=makerguides-20& linkCode=ll1&tag=makerguides-20&
linkId=e6745e523bbdb6d5ed267fde98509ff5&linkId=e6745e523bbdb6d5ed267fde98509ff5&
language=en_US) language=en_US)
([Link] Arduino Uno Rev3 ([Link]
Breadboard ([Link]
Jumper wires ([Link]
([Link] Capacitor ([Link] (100 µF)
Power supply ([Link]
(8-35 V)
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
3 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Small screwdriver ([Link] ([Link]
/2SkE0ms)
([Link] ([Link] ([Link]
/376RW7G)
/376RW7G)
Alligator test leads ([Link] (optional) ([Link]
/2sVeIRd)
Arduino IDE ([Link]
([Link] ([Link]
/en/Main/Software)
/en/Main/Software)
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
4 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
5 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
([Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
6 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
7 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
8 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
9 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
10 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
11 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
12 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
13 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Required connections to set the current limit
Downloads Motor Nameplate Inf… Ω Ste…
How To Control In-Depth Control Ste… Ωwith …
Stepper Motor 100% Clear
14 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
15 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
16 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
17 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
1. /*Example sketch to control a stepper motor with A4988 stepper motor
driver and Arduino without a library. More info:
[Link] */
2.
3. // Define stepper motor connections and steps per revolution:
4. #define dirPin 2
5. #define stepPin 3
6. #define stepsPerRevolution 200
7.
8. void setup() {
9. // Declare pins as output:
10. pinMode(stepPin, OUTPUT);
11. pinMode(dirPin, OUTPUT);
12. }
13.
14. void loop() {
15. // Set the spinning direction clockwise:
16. digitalWrite(dirPin, HIGH);
17.
18. // Spin the stepper motor 1 revolution slowly:
19. for (int i = 0; i < stepsPerRevolution; i++) {
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
18 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
20. // These four lines result in 1 step:
21. digitalWrite(stepPin, HIGH);
22. delayMicroseconds(2000);
23. digitalWrite(stepPin, LOW);
24. delayMicroseconds(2000);
25. }
26.
27. delay(1000);
28.
29. // Set the spinning direction counterclockwise:
30. digitalWrite(dirPin, LOW);
31.
32. // Spin the stepper motor 1 revolution quickly:
33. for (int i = 0; i < stepsPerRevolution; i++) {
34. // These four lines result in 1 step:
35. digitalWrite(stepPin, HIGH);
36. delayMicroseconds(1000);
37. digitalWrite(stepPin, LOW);
38. delayMicroseconds(1000);
39. }
40.
41. delay(1000);
42.
43. // Set the spinning direction clockwise:
44. digitalWrite(dirPin, HIGH);
45.
46. // Spin the stepper motor 5 revolutions fast:
47. for (int i = 0; i < 5 * stepsPerRevolution; i++) {
48. // These four lines result in 1 step:
49. digitalWrite(stepPin, HIGH);
50. delayMicroseconds(500);
51. digitalWrite(stepPin, LOW);
52. delayMicroseconds(500);
53. }
54.
55. delay(1000);
56.
57. // Set the spinning direction counterclockwise:
58. digitalWrite(dirPin, LOW);
59.
60. //Spin the stepper motor 5 revolutions fast:
61. for (int i = 0; i < 5 * stepsPerRevolution; i++) {
62. // These four lines result in 1 step:
63. digitalWrite(stepPin, HIGH);
64.
Downloads delayMicroseconds(500);
Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
19 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
65. digitalWrite(stepPin, LOW);
66. delayMicroseconds(500);
67. }
68.
69. delay(1000);
70. }
#define
dirPin
stepsPerRevolution
3. // Define stepper motor connections and steps per revolution:
4. #define dirPin 2
5. #define stepPin 3
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
20 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
6. #define stepsPerRevolution 200
setup()
pinMode()
8. void setup() {
9. // Declare pins as output:
10. pinMode(stepPin, OUTPUT);
11. pinMode(dirPin, OUTPUT);
12. }
loop()
15. // Set the spinning direction clockwise:
16. digitalWrite(dirPin, HIGH);
17.
18. // Spin the stepper motor 1 revolution slowly:
19. for(int i = 0; i < stepsPerRevolution; i++)
20. {
21. // These four lines result in 1 step:
22. digitalWrite(stepPin, HIGH);
23. delayMicroseconds(2000);
24. digitalWrite(stepPin, LOW);
25. delayMicroseconds(2000);
26. }
digitalWrite()
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
21 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
for(int i = 0; i < 100; i++)
delayMicroseconds()
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
22 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
([Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
23 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
1. /*Example sketch to control a stepper motor with A4988 stepper motor
driver, AccelStepper library and Arduino: continuous rotation. More info:
[Link] */
2.
3. // Include the AccelStepper library:
4. #include <AccelStepper.h>
5.
6. // Define stepper motor connections and motor interface type. Motor
interface type must be set to 1 when using a driver:
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
24 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
7. #define dirPin 2
8. #define stepPin 3
9. #define motorInterfaceType 1
10.
11. // Create a new instance of the AccelStepper class:
12. AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
13.
14. void setup() {
15. // Set the maximum speed in steps per second:
16. [Link](1000);
17. }
18.
19. void loop() {
20. // Set the speed in steps per second:
21. [Link](400);
22. // Step the motor with a constant speed as set by setSpeed():
23. [Link]();
24. }
#include <AccelStepper.h>
3. // Include the AccelStepper library:
4. #include <AccelStepper.h>
#define
dirPin
6. // Define stepper motor connections and motor interface type. Motor
Downloads interface type
Motor Nameplate mustHow
Inf… beToset toSte…
Control 1 whenIn-Depth
using a driver:
Control Ste… Stepper Motor with … 100% Clear
25 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
7. #define dirPin 2
8. #define stepPin 3
9. #define motorInterfaceType 1
AccelStepper liftmotor =
AccelStepper(motorInterfaceType, stepPin, dirPin);
11. // Create a new instance of the AccelStepper class:
12. AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
setup()
14. void setup() {
15. // Set the maximum speed in steps per second:
16. [Link](1000);
17. [Link](500);
18. }
loop()
setSpeed()
[Link]()
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
26 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
[Link](-400);
19. void loop() {
20. // Set the speed in steps per second:
21. [Link](400);
22. // Step the motor with a constant speed as set by setSpeed():
23. [Link]();
24. }
[Link]()
1. /*Example sketch to control a stepper motor with A4988 stepper motor
driver, AccelStepper library and Arduino: number of steps or revolutions.
More info: [Link] */
2.
3. // Include the AccelStepper library:
4. #include <AccelStepper.h>
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
27 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
5.
6. // Define stepper motor connections and motor interface type. Motor
interface type must be set to 1 when using a driver:
7. #define dirPin 2
8. #define stepPin 3
9. #define motorInterfaceType 1
10.
11. // Create a new instance of the AccelStepper class:
12. AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
13.
14. void setup() {
15. // Set the maximum speed in steps per second:
16. [Link](1000);
17. }
18.
19. void loop() {
20. // Set the current position to 0:
21. [Link](0);
22.
23. // Run the motor forward at 200 steps/second until the motor reaches
400 steps (2 revolutions):
24. while([Link]() != 400)
25. {
26. [Link](200);
27. [Link]();
28. }
29.
30. delay(1000);
31.
32. // Reset the position to 0:
33. [Link](0);
34.
35. // Run the motor backwards at 600 steps/second until the motor reaches
-200 steps (1 revolution):
36. while([Link]() != -200)
37. {
38. [Link](-600);
39. [Link]();
40. }
41.
42. delay(1000);
43.
44. // Reset the position to 0:
45. [Link](0);
46.
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
28 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
47. // Run the motor forward at 400 steps/second until the motor reaches
600 steps (3 revolutions):
48. while([Link]() != 600)
49. {
50. [Link](400);
51. [Link]();
52. }
53.
54. delay(3000);
55. }
currentPosition()
[Link](0)
20. // Set the current position to 0:
21. [Link](0);
setSpeed()
22. // Run the motor forward at 200 steps/second until the motor reaches
400 steps (2 revolutions):
23. while([Link]() != 400)
24. {
25. [Link](200);
26. [Link]();
27. }
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
29 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
1. /*Example sketch to control a stepper motor with A4988 stepper motor
driver, AccelStepper library and Arduino: acceleration and deceleration.
More info: [Link] */
2.
3. // Include the AccelStepper library:
4. #include <AccelStepper.h>
5.
6. // Define stepper motor connections and motor interface type. Motor
interface type must be set to 1 when using a driver:
7. #define dirPin 2
8. #define stepPin 3
9. #define motorInterfaceType 1
10.
11.
Downloads
// Motor
Create a new instance
Nameplate Inf…
of the AccelStepper
How To Control Ste…
class:
In-Depth Control Ste… Stepper Motor with … 100% Clear
30 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
12. AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
13.
14. void setup() {
15. // Set the maximum speed and acceleration:
16. [Link](200);
17. [Link](30);
18. }
19.
20. void loop() {
21. // Set the target position:
22. [Link](600);
23. // Run to target position with set speed and acceleration/deceleration:
24. [Link]();
25.
26. delay(1000);
27.
28. // Move back to zero:
29. [Link](0);
30. [Link]();
31.
32. delay(1000);
33. }
setAcceleration()
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
31 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
14. void setup() {
15. // Set the maximum speed and acceleration:
16. [Link](200);
17. [Link](30);
18. }
[Link]()
[Link]()
21. // Set the target position:
22. [Link](600);
23. // Run to target position with set speed and acceleration/deceleration:
24. [Link]();
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
32 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
33 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
34 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
35 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
36 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
37 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
38 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
39 of 40 2/18/2020, 10:21 PM
Stepper Motor with A4988 and Arduino Tutorial (4 Examples) [Link]
Downloads Motor Nameplate Inf… How To Control Ste… In-Depth Control Ste… Stepper Motor with … 100% Clear
40 of 40 2/18/2020, 10:21 PM