Controlling a servo with 2 buttons button control

Ok I need a little help with this. What im trying to do is make my servo move right when i hold down button 1, or move left when i hold down button 2. I say hold down said buttons because if i let go of the button i want the servo to stop and stay.

I need help setting up the hardware and software.

I'm using buttons or "High" and "Low" because in the end im going to be using a 2 button wireless rf controller to move the servo. Should be an ez way to move the servo wireless for pan and tilt on my outside cams, but i'm sure if i can get this working there will be much more things that can be down with it.

Thank you for all your help

Here is (an untested) modification to one of the Servo example sketches that should get you going in the righ direction

#include <Servo.h> 
 
Servo myservo; 
#define leftPin 2
#define rightPin 3
int pos = 90;
int delayPeriod = 50;  // increasing this slows down the servo movement

 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  myservo.write(pos); // center the servo
  pinMode(leftPin, HIGH);   // turn on pullup resistors
  pinMode(rightPin, HIGH);
} 
 
 
void loop() 
{ 
  if(digitalRead(leftPin) == LOW)  
  {                              
   // in steps of 1 degree 
   if( pos > 0)
      --pos;
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(delayPeriod);                      
  } 
  if(digitalRead(rightPin) == LOW)  
  {                              
   if( pos < 180)
       ++pos;
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(delayPeriod);        
  }
}

could you do me a favor and edit out the scrolling text in your post, I find it very distracting

could you do me a favor and edit out the scrolling text in your post, I find it very distracting

I second that motion. It distracts from the main message, and is an inducement to just move on to someone else's post.

The message itself is fine, it's the scrolling motion that is distracting.

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write(pos); // center the servo
  pinMode(leftPin, HIGH);   // turn on pullup resistors
  pinMode(rightPin, HIGH);
}

What is the use of the pullup resistors?

What is the use of the pullup resistors?

To ensure that when the button is not pushed the input receives a steady logic one. Without it the input will float and give random values of HIGH and LOW.

If you are new to Arduino digital pins, this tutorial provides useful background: http://www.arduino.cc/en/Tutorial/DigitalPins