Starting a loop using a switch

Well one thing to consider is simply making the switch a power switch for the Arduino so that your loop function will start to run on power on. This won't work if you need to have the Arduino on all the time to save variables, light LEDS, or if you're not checking for the switch at the start of your code, just thought I'd mention it. Using a while loop would look something like this, I'm no expert but I think this would work fine.

const int switchPin=2;
int switchState = 0;

void setup()
{
  pinMode(switchPin, INPUT); 
}

void loop()
{
  switchState = digitalRead(switchPin);
  
  while (switchState == 0){
    switchState = digitalRead(switchPin);
    delay (10);
  }
  
  //Code You wish to run after switch is thrown
}

This would use a SPDT switch with the center pin hooked to the IO and with each side pin attached to VCC and GND respectively. Your main loop should stay inside the while loop checking every 10 msec for the input to change to positive at which point it will move forward with the rest of your main loop, should you switch back to ground the code will be caught by the while loop on its next go around. I'm sure there may be a better way to handle this but I think it should do the trick. You can also put the while anywhere throughout your code where you want it to wait for the switch. Hope this helps.