Hi guys, I'm working on stepper motor and want to know how to make it change direction with reference of 0-255 pwm input for e.g if I increase pwm from 0-255 motor should go forward complete revolution and again if I decrease from 255-0 it should reverse complete revolution.
The stepper motor driver usually has a direction input to tell it directions. If you are not using a stepper driver, then please post your code and a diagram of how it is wired.
PWM (analogWrite() ) has nothing to do with controlling a stepper motor.
Perhaps you mean a servo which requires Servo.write()?
Hi, I'm using unipolar motor 12vdc with uln2003A, and tried the example code in which it is going some step forward and reverse but what I want is to control it from Bluetooth app which is having a slider providing 0-255 pwm output at pin 6 so I want to read and use that slider 0-255 to turn stepper forward and reverse .
I have not written any program yet as I'm clueless any help is appreciated. Thanks.
Post a link to the datasheet for your motor.
If it is a 28BYJ motor there are dozens of Forum Threads about them.
If you have a value from 0 to 255 and want forward and reverse a simple solution is
127 - number which will give you a range -128 to +127. Then you can move forward for the positive values and reverse for the negative values.