Home » ESP32 and Stepper motor example

ESP32 and Stepper motor example

by shedboy71

In this example we will show a basic stepper motor example, we use a driver board that can be bought on many sites which basically comprises of a ULN2003 IC and a few other components, you can use either 5v or 12v, the motor that comes quite often with this board is a 5v type, you can see it further down the page.

Here is the board that I used for this example and here are the connections

Wemos LOLIN32 IO15 -> IN1
Wemos LOLIN32 IO2 -> IN2
Wemos LOLIN32 IO0 ->IN3
Wemos LOLIN32 IO4 -> IN4

 

Diameter: 28mm; Voltage: 5V; Step angles: 5.625 x 1/64; Speed reduction ratio: 1/64; Power consumption: About 5V / 63mA; Load pull in frequency: >500Hz; Load pull out frequency: > 900Hz; 5-wire 4-phase can be driven with an ordinary ULN2003A chip

I powered the module externally

There are other similar boards where the motor is separate from the board but its the same stepper motor and it uses a ULN2003

 

Code

The code uses the built in stepper library, this is a fairly basic example

 

[cpp]
#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution

// initialize the stepper library on pins 15,2,0,4
Stepper myStepper(stepsPerRevolution, 15,2,0,4);

int stepCount = 0; // number of steps the motor has taken

void setup() {

}

void loop() {
// step one step:
myStepper.step(1);
stepCount++;
delay(100);
}
[/cpp]

 

 

Links

5V 4-phase Stepper Motor+ Driver Board ULN2003

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.