different action based on the number of times a button is pressed

John thanks for the second link, I've done a copy and paste

Here is an example of countdown using a for loop:

1234567891011
// countdown using a for loop
#include
using namespace std;
int main ()
{
for (int n=10; n>0; n--) {
cout << n << ", ";
}
cout << "FIRE!\n";
return 0;
}
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, FIRE!

I don't think there is a better way to learn then to see an example of how its done.
Here is my working code: with better comments

#include <Servo.h> 

Servo myservo1;  // create servo object to control a servo 
// a maximum of eight servo objects can be created 

float pos = 0;    // variable to store the rotary switch input



void setup() {
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object 
  myservo1.write(pos);
  delay(3000);
}

// the loop routine runs over and over again forever:
void loop() {

  int sensorValue = analogRead(A0); // read value from rotary switch
  if (sensorValue > 100 && sensorValue < 200) // rotary switch position 1
  {


    // rise and fall code                      
    for (pos = 12.5; pos < 18; pos += .1){  // goes from 12.5  to 15 
      // in steps of .1  
      myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
      delay(25);                       // waits 15ms for the servo to reach the position 
    }

    delay(3000);

    for (pos = 18; pos>=12.5; pos-=.1) {    // goes from 15  to 12.5  

      myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
      delay(25);     // waits 15ms for the servo to reach the position 
    } 
  }
  else if (sensorValue > 200 && sensorValue < 400) // rotary switch position 2
  {
    pos=13;
  }
  else if (sensorValue > 400 && sensorValue < 600) {// rotary switch position 3
    pos=14;
  }  
  else if (sensorValue > 600 && sensorValue < 700) {// rotary switch position 4
    pos=15;
  }
  else if (sensorValue > 700 && sensorValue < 900) {// rotary switch position 5
    pos=16;
  } 
  else if (sensorValue > 900) {// rotary switch position 6
    pos=17;
  } 


  myservo1.write(pos);

}

I really happy with how the program is coming along, due to all the help I have recieved. Next thing on my to do list is wire the switches to my breadboard and start experimenting.

John I was looking Jeremy Blum vid on youtube and seen a familiar name in the recommendations John NYCCNC is that you?
I've subscribed anyway, lots of very interesting vids to look at. I am a cnc'er myself, I've got a small vmc which I also use to turn small parts on which is what I made the air raid on, I've also biult my own router table.

Regards

Dale