Help with switching a stepper off

I'm using an Arduino motor shield and this code:

/*************************************************************
Motor Shield Stepper Demo
by Randy Sarafan

For more information see:
http://www.instructables.com/id/Arduino-Motor-Shield-Tutorial/

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

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, HIGH);   //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, LOW);   //Sets direction of CH B
  analogWrite(11, 1023);   //Moves CH B
  
  delay(delaylegnth);

}

I managed to loop it and delay, then change values to get it to stop/reverse but I'm kind of stumped on switching it on/off. I want to switch/run one direction, switch/run the opposite direction.

I've done switching with other things that use 1 pin but I'm confused about how to go about this because the several pins are operating in concert.

It's a stepper out of a computer CD drive that I'm using as a linear actuator. Pretty neat little dude if I can manage to control it properly!

Thanks!

Typically a motor shield when used for a stepper uses 4 outputs from the Arduino to turn on the 4 phases of the stepper in sequence.

The programming you are showing looks more like you are trying to control a DC motor.

Which motor are you trying to control?

Give us a little more info as to which Motor Shield you are using, and a link to the documentation would also be nice.

I'm using this shield:

http://arduino.cc/it/Main/ArduinoMotorShieldR3

It's a little bi-polar stepper with 4 wires. I've used this code to fire up 3 of them salvaged from old CD drives. (They are the little steppers that drive the laser diode carriage.) It took some fiddling to get the wire sequence correct but they seem to run fine. I can't get them to do anything with the example code even with changing the pin #'s in the code. With the shield the pin #'s are different and I haven't bothered to attempt figuring them out...

Here's some example code from the IDE:

/* 
 Stepper Motor Control - one revolution
 
 This program drives a unipolar or bipolar stepper motor. 
 The motor is attached to digital pins 8 - 11 of the Arduino.
 
 The motor should revolve one revolution in one direction, then
 one revolution in the other direction.  
 
  
 Created 11 Mar. 2007
 Modified 30 Nov. 2009
 by Tom Igoe
 
 */

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                     // for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,9,10,11);            

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
   Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  
   // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500); 
}

Well now... The example won't work if the pins on your board are different...

Looks like you need to turn the brake off, 5 V to the PWM and then A Fwd, B Fwd

Then to move you would cycle through A Rev B Fwd, A Rev B Rev, A Fwd B Rev, A Fwd B Fwd. repeat that sequence 50 times and the motor should turn 1 full turn. (200 Steps)
those are the 4 step values. To

If you want to use the stepper library you will need to figure out what pins you are using for each of those functions so that the library code will know what pins to use.