Need Help Controlling Bipolar.

HI every one.
I need quick help for controlling the bipolar motor that i have. I am using arduino uno + motor shield and i am using 4 wire A-A and B-B bipolar. I am using the code in the below but I like to add button that can be change the direction and also if i can i like to have to speed control. Any one have any idea? Please help.

*************************************************************/

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, 1023);   //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, 1023);   //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, 1023);   //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, 1023);   //Moves CH B
  
  delay(delaylegnth);

}

There are many motor shields - which one? What exactly is and isn't working?

I am using Arduino uno + arduino motor shield and i am using 4 wire bipolar from scanner. This code is the only code was working. i been searching many pages and try a lot of different codes but this one the only one working. Basically the 4 wire bipolar i am using like this AABB so that was the problem. Now this code is working but its working forever i like to do step by step like i should try to decide how many step i need and when is the step done stops and i will click the button and same thing will happen but reverse. If this possible?

dejavucurly:
I am using Arduino uno + arduino motor shield and i am using 4 wire bipolar from scanner. This code is the only code was working. i been searching many pages and try a lot of different codes but this one the only one working. Basically the 4 wire bipolar i am using like this AABB so that was the problem. Now this code is working but its working forever i like to do step by step like i should try to decide how many step i need and when is the step done stops and i will click the button and same thing will happen but reverse. If this possible?

The fact that the motor is, as you've called it "AABB", is not such an issue. It just means that you'd have to wire it slightly differently (I'm guessing pins 1,3,2,4 or something like that).

What you want to do is very possible, it's quite simple in fact. You'll want a counter variable that you increment on each loop, a check for a button press input on each loop, and when the press occurs you'll want to reset your counter. You'd also need a variable to indicate step direction that you would toggle on the button press, and the step sequence you'd send would have to differ based on the direction.

If the above sounds difficult to you then start with just a basic Arduino + some LEDs + a button, and experiment a bit. Also use the serial port and monitor in the Arduino IDE (i.e. in your code you can put a Serial.Println("Check A"), for example, and when that occurs it will appear in the serial monitor.