Starting and stopping a loop via a button

noweare:
Use pinMode() instead of setMode()

Thanks! That got rid of that error.

I tried recompiling but I end up with an error about reading the state of pins 7 and 8 with the code below producing the error:

sketch_new:24: error: expected ';' before ')' token

   pin7prevState = readState );

                             ^

sketch_new:34: error: expected ';' before ')' token

   pin8prevState = readState );

                             ^

exit status 1
expected ';' before ')' token
#include <Stepper.h>
const int stepsPerRevolution = 200;  //number of steps per revolution
// initialize the stepper library on pins 2 through 5:
Stepper myStepper(stepsPerRevolution, 2, 4, 3, 5);
int stepCount = 0;  // number of steps the motor has taken
int ledPin = 13; // set LED pin
byte processState;  // 0 is OFF, 1 is ON
byte pin7prevState;
byte pin8prevState;
byte readState;

void setup() 
{
 pinMode( 7, INPUT_PULLUP );  // wire this pin to a switch and the switch to ground
 pinMode( 8, INPUT_PULLUP );  // and put a 1 uF cap across both switches to debounce them
}

void loop() 
{
 readState = digitalRead( 7 );
 if ( pin7prevState != readState )
 {
  pin7prevState = readState );
  if ( readState == LOW ) // button down with INPUT_PULLUP drains the pin to ground.
  {
   processState = 1;
  }
 }

 readState = digitalRead( 8 ); // note that the stop button is read last. press both makes stop
 if ( pin8prevState != readState )
 {
  pin8prevState = readState );
  if ( readState == LOW ) // button down with INPUT_PULLUP drains the pin to ground.
  {
   processState = 0;
  }
 }

 if ( processState )
 {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) 
  {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 100);
  }
  digitalWrite(ledPin, HIGH);
 }
 else
 {
  // turn the motor and led off
  int motorSpeed = 0;
  digitalWrite (ledPin, LOW);
 }
}

Thank you so much for the help everyone, very appreciative.