So im currently trying to use a NEMA17 stepper motor with a A4988 driver. My objective is to control the speed and position of my motor according to sensor readings to position a contraption towards a light source. I found out that i can control it using servo controls using the arduino servo library. However, when using servo controls, positioning the motor with increments of 1 makes the motor rattle a lot. I tried using analogue write, but it seems the value that's written to the motor doesn't affect the speed. Most tutorials i see online involve turning on and off a pin in rapid succession 200 times to fully rotate the motor which is not really efficient in terms of code. Which method should i pick to control my motor?
not really efficient in terms of code
... why is it not efficient? ... please provide an example of inefficient code, if you can \$\endgroup\$