hi i wrote the following code which turns one stepper one time and then (lets a led blink) and reverses - this loops. i am learning my way through...
would anybody be so nice and explain to me how i can drive two steppers independently at the same time? for example i would have another easydriver connected to pins 4, 5 and would like to have this stepper turn only half while the original stepper turns like before.
// Schrittmotorsteuerung mit Easydriver Library
// MiPu 2011
//
// Motor 200 schritte/umdrehung, 8 fach microstepping -> 1600 schritte / umdrehung
int dirPin = 2;
int stepperPin = 3;
int LEDPin = 13;
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
pinMode(LEDPin, OUTPUT);
}
void step(boolean dir,int steps, int stp_int){
digitalWrite(dirPin,dir);
delay(50);
for(int i=0;i<steps;i++){
digitalWrite(stepperPin, HIGH);
delayMicroseconds(stp_int);
digitalWrite(stepperPin, LOW);
delayMicroseconds(stp_int);
}
}
void loop(){
step(true,1600,3000); // 1 umdrehung in 5 sekunden
digitalWrite(LEDPin, HIGH); // LED einschalten
delay(3000); // 1 sekunde warten
digitalWrite(LEDPin, LOW); // LED ausschalten
step(false,1600,3000); // 1 umdrehung zurück in 5 sekunden
digitalWrite(LEDPin, HIGH); // LED einschalten
delay(3000); // 1 sekunde warten
digitalWrite(LEDPin, LOW); // LED ausschalten
}
it would be great if somebody could help. have a nice day.