Motor stepper control, length movement


A sketch for controlling a servomotor looks like this:

/* Stepper Motor Control */

#include <Stepper.h>
const int stepsPerRevolution = 90;
// change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
   // set the speed at 60 rpm:
   // initialize the serial port:

void loop() {
   // step one revolution in one direction:
   // step one revolution in the other direction:

Can I control a stepper motor (28byj-48 + ULN2003) so as to obtain a length movement? Considering position 0 as the stepper axis, depending on the direction of rotation, to control the stepper so that an object in line with the axis moves e.g. 10 cm from position 0.
It would take building a conveyor belt, but you get the idea of the topic.

Sure it can. It is just a matter of knowing or figuring out how many steps you need per 1cm and then just move that many steps.

It is just math. Figure out how far one revolution moves the axis. For example (to make it simple), if one revolution moves the axis 9cm then 9cm/90 steps means each step moves the axis 1mm.

It all depends on how your axis works. If you are moving a belt, for example, then the circumference of the pulley dictates how far it moves. If you are using an ACME screw or ball screw then the screw pitch will define how many turns go how far.

I understand. Well, now I have to gather all the parts and try it.

Thanks for reply.