Microstepping and PWM

When I am using a microstepper, do I need to pwm in the code to control the speed of a stepper motor?

Stepper motors are not controlled by PWM. They are usually controlled by short step pulses with the speed determined by the interval between pulses. PWM is used to control the speed of a DC motor.

Post a link to the datasheet for your stepper motor and tell us what stepper motor driver you are using.

Have a look at these links
Stepper Motor Basics
Simple Stepper Code



Are you using the raw chip and building your own circuit board or have you bought the chip attached to a breakout board? if the latter it would be better to post a link to the datasheet for the breakout board.

I am not familiar with the chip but from a quick read of the datasheet I suspect you use the M1 M2 and M3 pins to select the microstepping mode and then the step pulses go to the CLK pin and the direction is determined by the CW/CCW pin.


I'd suggest starting with AccelStepper with DRIVER motor interface, ie

AccelStepper (DRIVER, step_pin, dir_pin);

Stepper drivers use step and direction signals to sequence microstepping. For instance DRV8825, A4988.