Skip to content

Commit af8e48f

Browse files
Change the order of the pins in the constructor
Since Stepper.h library uses `1010`, `0110`, `0101`, `1001` sequence for four-wire connection.
1 parent 85cbf26 commit af8e48f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

content/learn/04.electronics/04.stepper-motors/stepper-library-examples.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ A stepper motor follows the turns of a potentiometer (or other sensor) on analog
5454
// create an instance of the stepper class, specifying
5555
// the number of steps of the motor and the pins it's
5656
// attached to
57-
Stepper stepper(STEPS, 8, 9, 10, 11);
57+
// (note the order for 2th and 3th pins)
58+
Stepper stepper(STEPS, 8, 10, 9, 11);
5859
5960
// the previous reading from the analog input
6061
int previous = 0;
@@ -88,7 +89,8 @@ const int stepsPerRevolution = 200; // change this to fit the number of steps p
8889
// for your motor
8990
9091
// initialize the stepper library on pins 8 through 11:
91-
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
92+
// (note the order for 2th and 3th pins)
93+
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
9294
9395
void setup() {
9496
// set the speed at 60 rpm:
@@ -121,7 +123,8 @@ const int stepsPerRevolution = 200; // change this to fit the number of steps p
121123
// for your motor
122124
123125
// initialize the stepper library on pins 8 through 11:
124-
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
126+
// (note the order for 2th and 3th pins)
127+
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
125128
126129
int stepCount = 0; // number of steps the motor has taken
127130
@@ -153,7 +156,8 @@ const int stepsPerRevolution = 200; // change this to fit the number of steps p
153156
154157
155158
// initialize the stepper library on pins 8 through 11:
156-
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
159+
// (note the order for 2th and 3th pins)
160+
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
157161
158162
int stepCount = 0; // number of steps the motor has taken
159163
@@ -173,4 +177,4 @@ void loop() {
173177
myStepper.step(stepsPerRevolution / 100);
174178
}
175179
}
176-
```
180+
```

0 commit comments

Comments
 (0)