I want to use this sketch with my Uno and easy driver and a nema 17. It works but the motor just barely moves, but it is working.
#include <Stepper.h>
const int stepsPerRevolution = 200; // 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);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// nothing to do inside the setup
}
void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
// set the motor speed:
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
}
}
I have my wiring like this, (easy driver - direction to pin 8) (easy driver - Stepping to pin 9) (easy driver - ground to ground)
Potentiometer to 0. (typical setup)
What changes do I need to make so it works as it should.
This sketch works perfectly,
[code][code]#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(1, 9, 8);
int pos = 3600;
void setup()
{
stepper.setMaxSpeed(3000);
stepper.setAcceleration(1000);
}
void loop()
{
if (stepper.distanceToGo() == 0)
{
delay(500);
pos = -pos;
stepper.moveTo(pos);
}
stepper.run();
}
[/code][/code]
But I want to be able to set the speed of the stepper with a potentiometer, so I guess what I really want to do is to marry these two sketches, but I can't seem to do it.