Hello everyone, I write this message urgently because I have to realize a project that is in a week, I want to run a bipolar stepper motor with an Arduino Uno and Motor Shield in one direction for a given time, wait a certain number of seconds before turning it in the other direction for a given time, all once. The motor is connected to Motor Shield terminals A and B
I found the following code to run the motor infinitely in one direction :
int delaylegnth = 30;
void setup() {
Â
 //establish motor direction toggle pins
 pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
 pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???
Â
 //establish motor brake pins
 pinMode(9, OUTPUT); //brake (disable) CH A
 pinMode(8, OUTPUT); //brake (disable) CH B
Â
Â
}
void loop(){
 digitalWrite(9, LOW); //ENABLE CH A
 digitalWrite(8, HIGH); //DISABLE CH B
 digitalWrite(12, HIGH); //Sets direction of CH A
 analogWrite(3, 255); //Moves CH A
Â
 delay(delaylegnth);
Â
 digitalWrite(9, HIGH); //DISABLE CH A
 digitalWrite(8, LOW); //ENABLE CH B
 digitalWrite(13, LOW); //Sets direction of CH B
 analogWrite(11, 255); //Moves CH B
Â
 delay(delaylegnth);
Â
 digitalWrite(9, LOW); //ENABLE CH A
 digitalWrite(8, HIGH); //DISABLE CH B
 digitalWrite(12, LOW); //Sets direction of CH A
 analogWrite(3, 255); //Moves CH A
Â
 delay(delaylegnth);
 Â
 digitalWrite(9, HIGH); //DISABLE CH A
 digitalWrite(8, LOW); //ENABLE CH B
 digitalWrite(13, HIGH); //Sets direction of CH B
 analogWrite(11, 255); //Moves CH B
Â
 delay(delaylegnth);
}
And in the other direction :
int delaylegnth = 30;
void setup() {
Â
 //establish motor direction toggle pins
 pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
 pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???
Â
 //establish motor brake pins
 pinMode(9, OUTPUT); //brake (disable) CH A
 pinMode(8, OUTPUT); //brake (disable) CH B
Â
Â
}
void loop(){
 digitalWrite(9, LOW); //ENABLE CH A
 digitalWrite(8, HIGH); //DISABLE CH B
 digitalWrite(12, HIGH); //Sets direction of CH A
 analogWrite(3, 255); //Moves CH A
Â
 delay(delaylegnth);
Â
 digitalWrite(9, HIGH); //DISABLE CH A
 digitalWrite(8, LOW); //ENABLE CH B
 digitalWrite(13, HIGH); //Sets direction of CH B
 analogWrite(11, 255); //Moves CH B
Â
 delay(delaylegnth);
Â
 digitalWrite(9, LOW); //ENABLE CH A
 digitalWrite(8, HIGH); //DISABLE CH B
 digitalWrite(12, LOW); //Sets direction of CH A
 analogWrite(3, 255); //Moves CH A
Â
 delay(delaylegnth);
 Â
 digitalWrite(9, HIGH); //DISABLE CH A
 digitalWrite(8, LOW); //ENABLE CH B
 digitalWrite(13, LOW); //Sets direction of CH B
 analogWrite(11, 255); //Moves CH B
Â
 delay(delaylegnth);
}
In addition, I wish it all launches after pressing a button whose code is:
pinBouton=6;Â
 pinMode(pinBouton,INPUT);
}
void loop(){
 boolean etatBouton = digitalRead(pinBouton);
Â
Â
 if (etatBouton==HIGH)
So, I am writing to you to know how to periodize the time of the rotations, and add a delay in the middle. Thank you very much for your precious help