Hi, I am new of the Arduino programming, I had purchased a stepper motor which integrated with the controller. I had writing some code and try to driving the motor rotate faster. But I can not realize my purpose, It cost 15 seconds to run a cycle. It has slightly change when I reduce the delay but the difference in 1-2 seconds different.
The code as following shown.
// Define pin connections & motor's steps per revolution
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;
void setup()
{
// Declare pins as Outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int x = 0;
// Set motor direction clockwise
digitalWrite(dirPin, HIGH);
// Spin motor slowly
for(int x = 0; x < 50 * stepsPerRevolution; x++)
{
Serial.println(x);
digitalWrite(stepPin, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin, LOW);
delayMicroseconds(500);
}
}
Hope anyone who had played with Step/Dir control can give me some suggestion to increase the rotational speed.