mmcp42,
thanks for this:
while (true)
{
digitalWrite(step_pin, HIGH);
delayMicroseconds(10);
digitalWrite(step_pin, LOW);
delay(2250)
}
it tried it out. works better than I had but it still creates an issue with the motor occasionally stepping backward.
here's something else I have going which is working to some extent but still runs issue with the occasional backward step as well. It's also quite jerky. Here is:
////////////////////////////////////////////////////////
// Stepper Motor skecth for use with the EasyDriver 3.1 ///////////////////////
/////////////////////////////////
// Dan Thompson 2008 //
// modified by Robert Hengeveld 2011 //
// Inpired by the code and chat on this thread.
// http://forum.sparkfun.com/viewtopic.php?t=10378&highlight=easydriver //
// Use this code at your own risk. // For all the product details visit http://greta.dhs.org/EasyDriver/
// For the full tutorial visit http://danthompsonsblog.blogspot.com/ //
int dirpin = 3;
int steppin = 12;
void setup() {
Serial.begin(9600);
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}
void loop() {
int i;
digitalWrite(dirpin, LOW); // Set the direction.
delay(100);
Serial.println(">>");
for (i = 0; i<20; i++) // Iterate for 20 microsteps.
{
digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
delayMicroseconds(300); //
} // particular motor. Any faster the motor stalls. (could maybe go faster - decrease the Microseconds between steps)
digitalWrite(dirpin, HIGH); // Change direction.
delay(1000);
} // end of loop
I've been looking into the option of coding in 'setSpeed(rpm)' or 'step(200)' but haven't found the right sample code or tutorial. I've also consider having it switching the 'sleep' or 'enable' high and low in order to slow things down while conserving some energy at the same time?