Servo controlling using buttons instead of potentiometer

Hi, have an project going on that envolve one "big" rc servo. I want to have 2 push buttons (impulse buttons) that activate the servo left and right and two (impuls) buttons that adjust the travel +/- in steps of lets say 2 degrees, is this possible? I have search the internet and can't find a project like this. It may also work to have 3 different travel lengths to choose from in 3 different push buttons (impulse buttons) Any suggestions?

I've never actually used servos, but it should be trivial once you understand the servo library...

The servo angle is determined in software, and there's no "rule" that says the software has to be controlled by a pot. In fact, you don't need any controls or switches at all... You could program it to move 2 degrees ever 10 minutes, and then go back to zero after an hour.

It sounds like a fairly specific and unusual set of requirements and it is unlikely you will find somebody else's solution that matches your requirements exactly. In that case you will need to write your own solution. What you've described so far would not be complicated to code and you will find examples that show you how to read inputs and move servos.

This sketch with two buttons will get you started.

#include <Servo.h> 
 
Servo myservo; 
#define leftPin 2    //Active Low
#define rightPin 3   //Active Low
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);        
  }
}

nice, thank you guys. i'm quite new to this kind of programming, but i find arduino very interesting. I read and watch tutorials online ervery night now, hoping to get some sort of understanding :P

Mattgus: I read and watch tutorials online ervery night now, hoping to get some sort of understanding

You should supplement that with practical experience with the many examples that come with the Arduino IDE.

The problem you posed in your first post is more of a logic problem than a coding problem.

You should be able to work out a system that will achieve what you want before you ever need to think about implementing it is a specific programming language. Try writing out the steps on a piece of paper and following through several iterations of those steps on a second piece of paper.

...R