Stepper Motor Drive Problem

All,
I’m having problems with my sketch to run a stepper motor. This is what I’m trying
to do. I start with my stepper set at 0° I turn on my Arduino UNO and give it a start input from a push button (start the motor turning). The input of the push button is used to generate an output (pin 12 high) which is applied to an And gate (SN74LS08) on my driver board to start the motor. I want to look for an input from the switch two times, at the start of the run loop and at the end, this way I will keep the stepper motor synchronize with the program. The first switch input (start) works OK, but when I add the sceond switch input (stop) this is where I‘m having the problem.
Here is the error message I am getting.
Help!!!!!!!!!!

Stepper_Motor_with_Button.cpp: In function 'void loop()':
Stepper_Motor_with_Button:121: error: expected `}' at end of input

/*
Stepper motor 200 pluses per rev.
Turns on a coil for 5 milis , then off for 5 milis, repeatedly.
I used the Blink shetch to run the stepper motor and the analog
input shetch to get the delay time.
john Mims, Fl.
*/
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 12; // the number of the LED pin

// Variables will change:
int ledState = LOW; // the current state of the output pin
int lastButtonState = LOW; // the previous debounced button state
int lastReading= LOW; // the previous reading from the input pin
int sensorPin = A0;
int STP1 = 8; // stepper 1 coil output
int STP2 = 9; // stepper 2 coil output
int STP3 = 10; // stepper 3 coil output
int STP4 = 11; // stepper 4 coil output
int STP5 = 13; // run indicator
int sensorValue = 0;
int mappedValue;

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the input pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(STP1, OUTPUT);
pinMode(STP2, OUTPUT);
pinMode(STP3, OUTPUT);
pinMode(STP4, OUTPUT);
pinMode(STP5, OUTPUT);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);

// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
if (reading != lastReading) {
// reset the debouncing timer
lastDebounceTime = millis();
// save the reading. Next time through the loop,
// it'll be lastReading:
lastReading = reading;
}

if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so accept the button changed state:

// toggle the LED if the state of the button changes from LOW to HIGH:
if (lastButtonState == LOW && reading == HIGH) {
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(ledPin, ledState);
}
lastButtonState = reading;
//start the spepper motor turning to 36 deg.
digitalWrite(STP5, HIGH); // out test
delay(5);
digitalWrite(STP1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5); // wait for 5 milisecond
digitalWrite(STP1, LOW); // turn the LED off by making the voltage LOW
delay(5); // wait for 5 milisecond
digitalWrite(STP2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5); // wait for 5 milisecond
digitalWrite(STP2, LOW); // turn the LED off by making the voltage LOW
delay(5); // wait for 5 milisecond
digitalWrite(STP3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5); // wait for 5 milisecond
digitalWrite(STP3, LOW); // turn the LED off by making the voltage LOW
delay(5); // wait for 5 milisecond
digitalWrite(STP4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5); // wait for 5 milisecond
digitalWrite(STP4, LOW); // turn the LED off by making the voltage LOW
delay(5); // wait for 5 milisecond
digitalWrite(STP5, LOW); // turn off led 13 for test
sensorValue = analogRead(sensorPin); // Read the value of the pot voltage
Serial.print("Time in 0 to 1023, bits, " );
Serial.println(sensorValue);
mappedValue = map(sensorValue, 0, 1023, 0, 6000);
mappedValue = (mappedValue*2);
Serial.print("Time in milisec " );
Serial.println(mappedValue);
delay(mappedValue); //Stop Stepper Motoer val time.
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);

// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
if (reading != lastReading) {
// reset the debouncing timer
lastDebounceTime = millis();
// save the reading. Next time through the loop,
// it'll be lastReading:
lastReading = reading;
}

if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so accept the button changed state:

// toggle the LED if the state of the button changes from LOW to HIGH:
if (lastButtonState == LOW && reading == HIGH) {
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(ledPin, ledState);
}
lastButtonState = reading;
}
}

Stepper_Motor_with_Button.cpp: In function 'void loop()':
Stepper_Motor_with_Button:121: error: expected `}' at end of input

The compiler is correct. You have more open braces than you have close braces. It looks like you only need to add one close brace.

Given that the length of your loop function is such that it is difficult to notice the problem, consider moving some of that code into separate functions. That series of digitalwrites and delays would make a good candidate for the first one.

OK dywOOd,
I'm not a programmer.
What goes and what stays?
I moved the stepper motor stop time delay after the second switch check.

Stepper_Motor_with_Button.cpp: In function 'void loop()':
Stepper_Motor_with_Button:121: error: expected `}' at end of input

// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);

// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
if (reading != lastReading) {
// reset the debouncing timer
lastDebounceTime = millis();
// save the reading. Next time through the loop,
// it'll be lastReading:
lastReading = reading;
}

if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so accept the button changed state:

// toggle the LED if the state of the button changes from LOW to HIGH:
if (lastButtonState == LOW && reading == HIGH) {
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(ledPin, ledState);
}
lastButtonState = reading;
delay(mappedValue); //Stop Stepper Motoer val time.
}
}

john
Mims, Fl

Put each { and } on its own line. Then, use Tools + Auto Format to fix that awful indenting. Your problem will then be staring you in the face.