General if/then question...

Hello...

My setup has a 5v input signal. When that signal is present, I have a simple if statement like below:

int switchPin = 7;   // set up pin 7 as switchPin
int val;   // variable to read pin status

void setup () 
{
  pinMode(switchPin, INPUT);  // set switchPin to input
  DDRB = B110000;  // set pins 12 & 13 as outputs
}

void loop()
{
  val = digitalRead(switchPin);
  if (val == LOW) 
  {
    PORTB = B110000; 
    delay (100);
    PORTB = B000000;
    delay (1000);
  }
}

My question is, is there a way that I can make it so that each time the 5v signal is present, the port manipulation settings change? For instance, let's say that I know the 5v signal is going to be there 10 times. Each time its present, I want the code to be different, like:

First time the 5v signal is present:
PORTB = 110000;
delay (100);
PORTB = B000000;
delay (1000);

Second time the 5v is present:PORTB = 110000;
delay (50);
PORTB = B000000;
delay (150);

Third time:
PORTB = 110000;
delay (400);
PORTB = B000000;
delay (900);

And so on...

Thanks for the help.

update moderator: added some code tags

You need a variable with the value incremented every time the switch is pressed. Then you can call different routines depending on the value of the variable.

I'm not sure you should write to PortB in the way you are. Bits 6 and 7 are the external clock and writing them as 0 may upset things. You can use AND and OR to clear or set specific bits without upsetting the others.

...R