Gm
This is stepeer.h code whitch work fine for me but i can use it , like you say
#include <Stepper.h>
const int stepsPerRevolution = 45; // 70% left
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 40 rpm:
myStepper.setSpeed(40);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:(left)
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(2000);//2 second pause
// step one revolution in the other direction:(right)
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(2000);//2 second pause
}
soo i try transfer this code in AccelStepeer.h library
#include <AccelStepper.h>
AccelStepper myStepper(AccelStepper::FULL4WIRE, 8, 9, 10, 11);
const int stepsPerRevolution = 45; // 70% left
void setup()
{
myStepper.setMaxSpeed(40.0);
myStepper.setSpeed(40);
}
void loop()
{
Serial.println("clockwise");
myStepper.move(stepsPerRevolution);
delay(2000);//2 second pause
Serial.println("counterclockwise");
myStepper.move(-stepsPerRevolution);
delay(2000);
// step one revolution in the other direction:(right)
// --or absolute positioning
Serial.println("counterclockwise");
myStepper.moveTo(-stepsPerRevolution);
myStepper.runSpeedToPosition();
delay(2000);//2 second pause*/
}
code upload succes but nothing hepend with motor, motor freeze, can i do this on this way or i nitu use aproximtely miles to define position left and right, and how i can connect this code with (for loop) so i can count numper of repeated steps (19 time ) ? i hope i put all what you need to see where im stuck
tnx for reply