Servo motor program

Often when I ask a question it ends up being something obvious, but right now it is not so obvious to me. I am trying to increment a servo motor up one degree (0-180) every time a button is pushed (buttonPin). I have an LED (ledPin) attached just as an indicator that tells me that the program is seeing the button pushed. There are no errors in the program but it is not working the way I want. Instead of increment one degree per button push the servo motor moves 180 degrees and then resets itself to 0.
below is the code.

const int buttonPin = 2;
const int ledPin = 4;
int buttonState = 0;
int buttonPushCounter = 0;
int lastButtonState = 0;
#include <Servo.h>;
Servo myServo;


void setup() {
  pinMode (buttonPin, INPUT);
  pinMode (ledPin, OUTPUT);
  myServo.attach(9);
}
  void loop() {
    buttonState = digitalRead (buttonPin);
    if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      digitalWrite (ledPin, HIGH);
      buttonPushCounter++;}
      for (buttonPushCounter>-1;buttonPushCounter<180;buttonPushCounter +=1){
        myServo.write(buttonPushCounter);
        delay(10);}}

    else {
      digitalWrite (ledPin, LOW);
      myServo.write(buttonPushCounter);
      delay (10);
    }
    lastButtonState = buttonState;
  }

Thank you.

It's because inside your if where it goes when the button state is high, you have the whole sweep 0-180 for.

You need to have the line that simply increments pos when it goes there, and then write that new pos.

I am trying to increment a servo motor up one degree (0-180) every time a button is pushed (buttonPin).

A discussion below that may have some info.

http://forum.arduino.cc/index.php?topic=287294.0

Thank you. I got rid of the

for (buttonPushCounter>-1;buttonPushCounter<180;buttonPushCounter +=1)

and it works they way I want it.

Thank you again.