Problem is that I can't get the code to work. I have made a post in the comments area on the address above under my name, Andreas Carmblad. I would really appreciate if someone could help me with this. I've tried this but can't understand what I'm doing wrong.
I've tried this but can't understand what I'm doing wrong.
Let me see if I understand this. You are running some code you didn't show us. It is doing something that you didn't describe. You want it to do something that you didn't describe. And, you want us to tell you what is wrong.
I'll get right on that, as soon as my crystal ball arrives. It's on back-order, with a promised date of the 12th of never. If you need help before then, I sincerely hope something occurs to you.
If you have an Easydriver this simple test code should make your motor move. Just keep in mind that the Pololu A4988 stepper driver defaults to single steps and I THINK the Easydriver defaults to microstepping. If so you should increase the number of steps - and maybe reduce the interval between steps.
// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0
byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 25; // milliseconds
void setup()
{
Serial.begin(9600);
Serial.println("Starting StepperTest");
digitalWrite(ledPin, LOW);
delay(2000);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(directionPin, HIGH);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
delay(3000);
digitalWrite(directionPin, LOW);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop()
{
}
As you have not given details of the motor you are using I cannot say whether it will work with an Easydriver.