Adding on to variable

I'm fairly new to Arduino, but I'm slowly figuring it out.

I have three different "Statuses", where it tells a servo to do something different at each status. I'm testing this with LED's right now.

My goal is that when I press my button, I want it to add one to the "Status Level", which would run that if statement, then when I hit it again, it would run the next status level and so on.

The problem is that when I connect my leds, and i press the button, it goes through status one (and runs it, flashes the first LED), and it continues to Status two(Where the second LED stays lit). How do I fix this. I've spend some time searching and googling but I can't seem to figure it out.

Below is a copy of the code I'm running. It's kind of messy and in the first stages.

Thanks,
David

/*General Info
Servo x is set to pin 5
Button is set to pin 2
*/

#include <Servo.h>

/*Status' --------------------------------------------------------------------
0. reset/default position

  1. move right/left
  2. Pull arm back
  3. Release throw
  4. Reset status
    */

//declaring variables----------------------------------------------------------
Servo servox;
int Status = 0;
int degreex = 90 ;
int button = 2 ;
int servo = 5;
int pressed = 0;

//Start of Setup ---------------------------------------------------------------
void setup() {
pinMode(13, OUTPUT);//red light
pinMode(12, OUTPUT);
//attaches hardware
servox.attach(5);
pinMode(button, INPUT); //states that the button is an input
}

void loop () {
pressed = digitalRead(button); //Links status to button
if(pressed == HIGH){
Status = Status + 1 ;

if(Status == 1) {
digitalWrite(13, HIGH);
}
if(Status == 2) {
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
}
}

I think what you need is to detect when the button becomes pressed, not when it is pressed.
Have a look a the state change examples.

Please use code tags when posting code.

In addition to what @AWOL has said you should realize that loop() repeats hundreds or thousands of times per second so it can increment Status many times while the button is pressed briefly.

...R

Thank you for your responses. I will look into when the button becomes pressed.

Dumb question, but what are the code tags? Lol

Dumb question, but what are the code tags? Lol

Read the two posts at the top of this Forum by Nick Gammon for guidelines on posting here. It also tells you what the code tags are.