Hi!
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:
myStepper.setSpeed(5);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
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.