moving a servo left & right with 2 buttons

Perhaps mem did a good enough explanation... but if you want, here is the code and a video to show how it works...

#include <MegaServo.h>

byte pin = 8;
byte pin2 = 7;
int pos = 90;
MegaServo servo;
void setup(){
 
 pinMode(pin, INPUT);  // initialize pins
  pinMode(pin2, INPUT);
  
  digitalWrite(pin, HIGH); // set internal pull up resistors
  digitalWrite(pin2, HIGH);

servo.attach(4);
}

void loop(){
 
 int val = digitalRead(pin); // get the button values... low is pressed... high is not pressed
int val2 = digitalRead(pin2);

if (val == 0){
  if (pos < 180 && pos > 0){
  
  pos+=2;
} if (pos == 180){
 pos = 178; 
}

if (pos == 0){
 pos = 2; 
}
} 

if (val2 == 0){
 if (pos < 180 && pos > 0){
  
  pos-=2;
} 
  if (pos == 180){
 pos = 178; 
}

if (pos == 0){
 pos = 2; 
}
  
}

servo.write(pos);
delay(15);
  
}

and the vid... :

http://bxsciborgs.com/rus.tech.studio/mypics/DSCN1158.MOV

it takes a while to load... sry.