// Define pin connections & motor's steps per revolution
const int dirPin = 2; const int dirPin_alt = 8;
const int stepPin = 3; const int stepPin_alt = 9;
int stepDelay=1000; int stepDelay_alt=10000;
void setup()
{
// Declare pins as Outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop(){
haha();
haha_2();
}
int haha(){
digitalWrite(dirPin, HIGH);
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
int haha_2(){
digitalWrite(dirPin_alt, HIGH);
digitalWrite(stepPin_alt, HIGH); //stepper motor rotate 5 times slower than haha() due to increased delay 5 times.
delayMicroseconds(5000);
digitalWrite(stepPin_alt, LOW);
delayMicroseconds(5000);
}
web hosting in Sri lanka
Hi all, I am trying to control 2 stepper motor, one with a speed of 5 times of the another one. I have written the code below, however it does not work for 2 stepper motor. I have make sure the power supply and current is enough to drive the small Nema 17 stepper motor:). I believe the problem is with the code. Is there a mistake somewhere in the code :)?
Thank you for reading and have a nice day:)