Nesting 2 loops & running a number of times within a 3rd loop

I’m having a bit of a problem getting my “test jig” project completed. Obviously, I have little experience with C++ and Arduino programming. Anyway, here’s what I “want” to do.
Run one sequence turning 12 individual relays on (one at a time) to run small DC motors for 10 seconds, then off, doing this for 30 cycles (I’ve done that.). Next, I want to reverse direction by turning 2 additional relays on to swap the plus and minus voltages (I’ve done that). Then, I want to run these motors in reverse 10 cycles of 10 seconds each. After this is completed, I want to go through the whole thing (both forward and reverse) 6 times. I can’t get the third “Big” loop, that contains the 2 smaller ones, to run.

I am attaching my code…

Relay_G1.ino (7.37 KB)

Learning to use for loops and arrays could cut that entire thing down to a handful of lines of code. For example, this:

#define RELAY1  2
#define RELAY2  6
#define RELAY3  3
#define RELAY4  7
#define RELAY5  4
#define RELAY6  8
#define RELAY7  5
#define RELAY8  9
#define RELAY9  10                       
#define RELAY11 11                      
#define RELAY13 12                  
#define RELAY15 13
#define RELAY14 14
#define RELAY16 16

void setup()
{    

  // Initialise the Arduino data pins for OUTPUT
  pinMode(RELAY1, OUTPUT);       
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  pinMode(RELAY5, OUTPUT);
  pinMode(RELAY6, OUTPUT);
  pinMode(RELAY7, OUTPUT);
  pinMode(RELAY8, OUTPUT);
  pinMode(RELAY9, OUTPUT);
  pinMode(RELAY11, OUTPUT);
  pinMode(RELAY13, OUTPUT);
  pinMode(RELAY15, OUTPUT);
  pinMode(RELAY14, OUTPUT);
  pinMode(RELAY16, OUTPUT);
}

Can be shortened to this:

#define ARRAY_COUNT(x) sizeof(x)/sizeof(x[0])
const int relayPins[] = {2, 6, 3, 7, 4, 8, 5, 9, 10, 11, 12, 13, 14, 16 }; 
void setup()
{
  for (int i=0; i < ARRAY_COUNT(relayPins); i++)
  {
    pinMode(relayPins[i], OUTPUT);
  }
}

Using methods like this allow repeating sections of code to be made easier; you just have to stuff the code into a for loop.

Thank you Arrch. It's quite obvious that I'm not a code guy. Maybe I can use "Morse Code", but I'll learn this stuff.