Simple question about turning on an output (modification of blink tutorial)

Hi All I am super new to this programming and feel like I ran into a very obvious roadblock and not sure how to fix it.

Two questions.

1) I am able to make the blink tutorial work, but my question is how do I do it without a loop. For example, I just want to turn on the output, wait xxx amount of seconds and then turn it off and end the program.

2) How do I activate the board through a pushbutton and not use the reset button on the board? What voltage do I use?

Thanks so much ahead of time.

This is the code I am using from the tutorial

const int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  
}

For example, I just want to turn on the output, wait xxx amount of seconds and then turn it off and end the program.

Easy way - do it in setup Smarter way - do it once in loop() and set a boolean variable to true when done. Check the value of the boolean before doing the on/off again Even better way - use millis() for timing as in the BlinkWithoutDelay example.

How do I activate the board through a pushbutton and not use the reset button on the board? What voltage do I use?

Leave the board powered all the time and check an input pin each time through loop(). When the pin goes HIGH or LOW (you choose) run the code that you want.

How do I activate the board through a pushbutton and not use the reset button on the board? What voltage do I use?

Do not use any voltage, wire the switch between input and ground and enable the pull up resistor. See this:- http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Thank you guys for the advice

Thanks guys, this is what I came up with for the one time run, will work on the button start now.

appreciate it

const int handpiece = 13;
const int valve = 12;
int x = 0;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
    pinMode(handpiece, OUTPUT);     
    pinMode(valve, OUTPUT);  
  }

// the loop routine runs over and over again forever:
void loop() {
  if (x == 0)
  digitalWrite(handpiece, HIGH);   // turn the handpiece on 
  delay(5000);               // time to leave handpiece on
  digitalWrite(valve, HIGH);   // turn the valve on 
  delay(5000);               // time to leave valve on
  digitalWrite(handpiece, LOW);    // turn the handpiece off 
  digitalWrite(valve, LOW);    // turn the valve off 
  delay(5000);               // time to leave valve on
  x = 1;
}

That looks like it will work but should you want to do anything else in loop() then the delay()s will get in the way, hence the suggestion to use millis() for timing as in BlinkWithoutDelay,

Do you need the final delay() in your code, particularly as it does not do what the comment says.

No, I actually removed it after posting. I will have to experiment with the millis because I also want to take readings from three different 0-5v analog sensors.