I am making a rubber band gun but i cant seem to get the button to work with my code to turn the servo? #include &lt;Servo.h&gt;
const int buttonPin = 3;
int buttonState = 0;

Servo myservo;   
void setup() {
    myservo.attach(2);    
    pinMode(buttonPin, INPUT);
}

void loop() {
    buttonState = digitalRead(buttonPin);   
    if (buttonState == HIGH){ myservo.write(90); }   
    else { myservo.write(155); }   
    delay(1000); 
}
Just put your button between pin3 and GND, and use the internal pullup resistor like this:

#include &lt;Servo.h&gt;
const int buttonPin = 3;
int buttonState = 0;

Servo myservo;   
void setup()
{
    myservo.attach(2);    
    pinMode(buttonPin, INPUT_PULLUP);
}

void loop()
{
    buttonState = digitalRead(buttonPin);
    if(buttonState == LOW)
    {
      myservo.write(90);
    }
    else
    {
      myservo.write(155);
    }   
    delay(1000); 
}