Help with sketch

hi, guys i have that code

void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);

}

void loop() 
{
  digitalWrite(13, HIGH);  
  digitalWrite(12, HIGH);
  delay(5000);
  digitalWrite(12, LOW);        
  digitalWrite(11, LOW);
  delay(5000);
  digitalWrite(11, HIGH);
  

}

works for three leds pin 13 led orange, pin 12 led red and pin 11 LED green, I want you to start the arduino I pledge the orange LED and the red, after 5 seconds, then exchange the red LED turns off and turn the green.

I don't understand.

Have a look at Planning and Implementing a Program. Notice that it does not use the delay() function.

...R

Keep in mind that the loop function gets repeated. So about a microsecond after you make pin 11 high the whole thing starts over and makes 12 and 13 high again.

and how to avoid the loop, or at least delay

Do you want orange and green stay on forever?

A simple counter will make your leds turn on/off only once. If statement will be true only first loop.

int a = 0;

void setup() {
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);

}

void loop()
{
  if (a < 1) {
    digitalWrite(13, HIGH);
    digitalWrite(12, HIGH);
    delay(5000);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    delay(5000);
    digitalWrite(11, HIGH);
    a++;
  }
}

perfect, I would like to remain always lit orange and green after the change and the red always off, now how could I do to add a button to start the function and another to cut

If you have a look at button tutorial, you can take the button related code. Instead of turn on a led, you simply reset 'a' back to zero. It will run your sequence one more time.

lun4tic0s:
and how to avoid the loop, or at least delay

If you want something to run only once, put it in setup instead of loop.

lun4tic0s:
and how to avoid the loop, or at least delay

And I don't understand this.

..R