Trouble with mini servo motor

I am fairly new to the world of Arduino and electronics. I am trying to control a mini servo with 2 pushbuttons, one to turn it left and one for right. I want the motor arm to increment/decrement by 10 degrees according to which button is pressed. The problem I am having is that the arm swings all the way to 0 or 180, rather than going by 10s. I tried to fix this several times in the code and I'm pretty sure I wired everything correctly. Code is posted below. Any help is greatly appreciated.

#include <Servo.h>  // servo library

Servo servo1;
const int buttonLPin = 2;
const int buttonRPin = 3;

int buttonLState;
int buttonRState;

const int ledPin = 13;

void setup()
{
  servo1.attach(9);
  
  pinMode(buttonLPin, INPUT);
  pinMode(buttonRPin, INPUT);
  
  pinMode(13, OUTPUT);
  servo1.write(90);
}

void loop()
{
  int position = servo1.read();
  
  int buttonLState;
  int buttonRState;

  buttonLState = digitalRead(buttonLPin);
  buttonRState = digitalRead(buttonRPin);
  
    if((buttonLState == LOW) && (buttonRState == HIGH))
    {
      servo1.write(position + 10);
    }
    
    if((buttonRState == LOW) && (buttonLState == HIGH))
    {
      servo1.write(position - 10);
    }
}

Please edit you post, and enclose you code with the "code"-tag.

You should know how to do this - You did read the first sticky-post in every forum, didn't you?

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

// Per.

It makes it much easier to follow code when it is properly presented in code tags.

The command servo.read() is really pointless - it doesn't get any info from the servo, it just uses data saved in the servo library. Your code would be much more transparent if you create a variable and save the position yourself whenever you send a command to change the servo position.

I suspect your problem is that loop() repeats thousands of times per second so a single press of the button appears to the Arduino as many presses. A crude solution would be to add delay(200);
after each servo.write(). This gives 200 milliseconds for you to take your finger off the button.

...R

It works fine now, thank you very much!