Running loop code for x times then run next line x times

Hello,

I did a search but didnt find the solotion. Hopfully you can help me .

I got this lines:

void loop()
{
//Wnt to run this for a x amount for times and then goto the nect to run it for an x amount of times.

So i want to excecute the next piece of code for 1500 times and the switch to the second part of the code and execute it foor 1500 times, then wait for 5 minutes en start over agoain.
//First part
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(50); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(79000); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(50); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(5000); // wait for a second

//second part
digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(50); // wait for a second
digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
delay(50); // wait for a second
digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
delay(50); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(5000); // wait for a second

// after this it has to start all over again.

First look at blink without delay to get rid to the delays. After that it simple

psuedo - code

loop(){
  for (1500 times){
     dothis();
  }
  for (1500 times){
    dothis1();
  }

  wait 5 mins

}

Mark

Thank you for the quick and good responce !!

Going to ty the code now.

It for an relay board that is controlling a antenna rotor with a wifi antenna to san accespoints. This way i can let it scan with litte steps and all the time.

Thank you!!

Roy

Oke i aint getting this :frowning: Maybe i'm to tired of overlooking something.
//this is my setup with gooed timing/delays
#define RELAY_ON 0
#define RELAY_OFF 1
#define Relay_1 2 // Arduino Digital I/O pin number
#define Relay_2 3
#define Relay_3 4
#define Relay_4 5
void setup()
{
//nitialize Pins so relays are inactive at reset)
digitalWrite(Relay_1, RELAY_OFF);
digitalWrite(Relay_2, RELAY_OFF);
digitalWrite(Relay_3, RELAY_OFF);
digitalWrite(Relay_4, RELAY_OFF);

//set pins as outputs
pinMode(Relay_1, OUTPUT);
pinMode(Relay_2, OUTPUT);
pinMode(Relay_3, OUTPUT);
pinMode(Relay_4, OUTPUT);
delay(4000); //Check that all relays are inactive at Reset

Above afcourse the setup an below the Loop

//---( Turn left Full sequence)---
void loop(){

digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(50); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(70; // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(50); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(5000); // wait for a second

}

digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
delay(50); // wait for a second
digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
delay(70); // wait for a second
digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
delay(50); // wait for a second
digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
delay(5000); // wait for a second

}

Can i ask you how to do this wwith the code you gave me and the no delay but hold the current timing

http://arduino.cc/en/Reference/For