user48289: How do I use 4 input lines as a binary decoder? I would like to read the 4 inputs (16 variations) and based on that choose one of 16 output behaviors? 
I need to be able to set my “Ten Moon Phase Indicator” (MPI ECP) circuit project to the phase of the Moon as seen in the sky on this day, or to a specific time as indicated in one of the many apps available on the Internet. Currently the MPI ECP resets to the start of the Full Moon loop, as it is the only loop available. (this code works) NOTE: Due to the circuit & Arduino processor power consumption for this application, a eternal power will be necessary. 
To resolve this problem my intent is to use four of the available 14 I\O on the Arduino Uno as INPUT's employing four debounced toggle switches (with pull up resistors): (0) Off, (1) as On. The other ten available I/O's to be used for the ten Moon display OUTPUT LED's or to control ten relays. 
What I would like the sketch program to accomplish:

digitalRead pins 0, 1, 12, 13
Depending on 1 of 16 resulting four on/off combinations that are possible, run a specific loop.

This is what I came up with: (note, the code does not compile, I'm new)
 void setup()  {
 pinMode(2, OUTPUT);   // New     Waxing:  
 pinMode(3, OUTPUT);   // Young  Waxing:
 pinMode(4,OUTPUT);   // Crescent Waxing:
 pinMode(5, OUTPUT);   // Quarter Waxing: 
 pinMode(6, OUTPUT);   // Gibbous Waxing: 
 pinMode(7,OUTPUT);   // Full Moon: 
 pinMode(8, OUTPUT);   // Gibbous Wanning:
 pinMode(9, OUTPUT);   // Quarter Wanning:
 pinMode(10, OUTPUT);  // Crescent Wanning: 
 pinMode(11, OUTPUT);  // Old Wanning: 
 pinMode(13, INPUT);  // Switch 4
 pinMode(12,INPUT);     // Switch 3
 pinMode(1, INPUT);     // Switch 2
 pinMode(0,INPUT);      // Switch 1 

 } void loop() {
 int Reading = digitalRead;
Reading = digitalRead (12); Reading = digitalRead (13);
Reading = digitalRead (1);   Reading = digitalRead (0); 

 if  (digitalRead(0) == HIGH; digitalRead (1)==
   HIGH; digitalRead(12) == HIGH; (digitalRead(13) == HIGH);  { } else 
    {   // loop Full Moon Start   digitalWrite(7, HIGH);  // FULL MOON ON
  delay(5000); 
  digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10);
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);  
 digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000); 
  digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);  
 digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
   digitalWrite(2, HIGH);  // NEW MOON ON
          delay(5000); 
  digitalWrite(2, LOW);   // NEW MOON OFF
          delay(10);  
 digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);  // YOUNG MOON OFF
          delay(100); 
 digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10); 
  digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);  
 digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);

// loop for New moon Reset   if  (digitalRead(0) == LOW;digitalRead (1)==LOW; digitalRead(12) == LOW;(digitalRead(13) ==
    LOW);  
  { } else   // loop New Moon Start
 digitalWrite(2, HIGH);  // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);   // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100);
   digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10);
   digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000); 
  digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10); 
  digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000);
   digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);  // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);
   digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10);
   digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);
   digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
 { } else  { // Young moon Reset Start 
 if  (digitalRead(0) == LOW; digitalRead (1)==LOW; digitalRead(12) ==
    LOW;(digitalRead(13) == HIGH;
 )
   { } else  // loop New Moon Start
         digitalWrite(3, HIGH);
  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100); 
  digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000); 
  digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10);
   digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000); 
  digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10); 
  digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10); 
 digitalWrite(7, HIGH);    // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000); 
  digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);  
 digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000); 
  digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
         digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);       // NEW MOON OFF
          delay(10);
  } 
 // Waxing Crescent Reset Start if  (digitalRead(0) == LOW; digitalRead (1)== LOW; digitalRead(12) ==
    HIGH; digitalRead(13) == HIGH;)    { } else  // Waxing Crescent Moon
    reset Start
  digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10); 
 digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);
   digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);    // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10);  
  digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);
   digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10);  
 digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);   digitalWrite(11, LOW);      // OLD MOON OFF
         delay(5000);
   digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);      // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);       // YOUNG MOON OFF
          delay(100);
  } 
  // First Quarter Moon Reset if  (digitalRead(0) == LOW; digitalRead(1) == HIGH; digitalRead(12) ==
    HIGH; digitalRead(13) == HIGH;)   { else  {
  //FIRST QUARTER  Moon
    reset Start
digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);
   digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);  // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000); 
  digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000); 
  digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
  digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000); 
  digitalWrite(2, LOW);    // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100);
   digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000); 
  digitalWrite(4, LOW);        // WAX CRESCENT MOON OFF
          delay(10); 
 } 
// code would continue with other loops. Thanks for looking at  my 16 RESET problem, email me. Any suggestions would be appreciated


user20533: a skeleton solution:
int in[] = {0,1,12,13};
int out[] = {2,3,4,5,6,7,8,9,10,11};
...
void setup()
{
    for(int i=0; i < 4; i++)
        pinMode(in[i], INPUT)

    for(int i=0; i < 10; i++)
        pinMode(out[i], OUTPUT)
}
...
void do0 {...};
void do1 {...};
void do2 {...};
void do3 {...};
void do4 {...};
void do5 {...};
void do6 {...};
void do7 {...};
void do8 {...};
void do9 {...};
void do10 {...};
void do11 {...};
void do12 {...};
void do13 {...};
void do14 {...};
void do15 {...};
...
void loop()
{
    int addr = 0;
    for(int i=0; i<4; i++)
       addr |= digitalRead(in[i]) << i;

    switch(addr)
    {
    case 0:
       do0();
       break;
    case 1:
       do1();
       break;
    case 2:
       do2();
       break;
    case 3:
       do3();
       break;
    case 4:
       do4();
       break;
    case 5:
       do5();
       break;
    case 6:
       do6();
       break;
    case 7:
       do7();
       break;
    case 8:
       do8();
       break;
    case 9:
       do9();
       break;
    case 10:
       do10();
       break;
    case 11:
       do11();
       break;
    case 12:
       do12();
       break;
    case 13:
       do13();
       break;
    case 14:
       do14();
       break;
    case 15:
       do15();
       break;
    }
}


user7508: This may be a little too advanced for the OP but... reading esoterik’s
answer, I couldn't help the urge to transform that big switch/case into
an array lookup. Admittedly, the syntax for declaring the array of
function pointers is a little bit esoteric. ;-)
void loop()
{
    // List of implemented behaviors.
    static void (* const behaviors[])() = {
        do0, do1, do2,  do3,  do4,  do5,  do6,  do7,
        do8, do9, do10, do11, do12, do13, do14, do15
    };

    // Build the index of the requested behavior.
    int addr = 0;
    for (int i = 0; i < 4; i++)
       addr |= digitalRead(in[i]) << i;

    // Now do it.
    behaviors[addr]();
}


Edit: To address the OP's issue. I may have missed something, but it
looks to me like all the cases do the exact same thing: loop through the
outputs, turn each one on, wait 5 seconds, then turn it off. The only
difference between the cases is the index of the output that is turned
on first. In this case, all this repetitive code can be factored into a
single loop as follows:
// Turn on then off all the outputs in turn,
// starting from the given index.
void loop_outputs(int start_index)
{
    int index = start_index;
    for (int count = 0; count < 10; count++) {

        // Light up that LED for 5 s.
        digitalWrite(out[index], HIGH);
        delay(5000);
        digitalWrite(out[index], LOW);
        delay(10);

        // Go to the next one, wrapping index 10 -> 0.
        if (++index == 10) index = 0;
    }
}


48289: <p>How do I use 4 input lines as a <a href="https://en.wikipedia.org/wiki/Binary_decoder" rel="nofollow noreferrer">binary decoder</a>? I would like to read the 4 inputs (16 variations) and based on that choose one of 16 output behaviors? </p>

<p>I need to be able to set my “Ten Moon Phase Indicator” (MPI ECP) circuit project to the phase of the Moon as seen in the sky on this day, or to a specific time as indicated in one of the many apps available on the Internet. Currently the MPI ECP resets to the start of the Full Moon loop, as it is the only loop available. (this code works) NOTE: Due to the circuit &amp; Arduino processor power consumption for this application, a eternal power will be necessary. </p>

<p>To resolve this problem my intent is to use four of the available 14 I\O on the Arduino Uno as INPUT's employing four debounced toggle switches (with pull up resistors): (0) Off, (1) as On. The other ten available I/O's to be used for the ten Moon display OUTPUT LED's or to control ten relays. </p>

<p>What I would like the sketch program to accomplish:</p>

<ol>
<li><code>digitalRead</code> pins <code>0</code>, <code>1</code>, <code>12</code>, <code>13</code></li>
<li>Depending on 1 of 16 resulting four on/off combinations that are possible, run a specific loop.</li>
</ol>

<p>This is what I came up with: (note, the code does not compile, I'm new)</p>

<pre><code> void setup()  {
 pinMode(2, OUTPUT);   // New     Waxing:  
 pinMode(3, OUTPUT);   // Young  Waxing:
 pinMode(4,OUTPUT);   // Crescent Waxing:
 pinMode(5, OUTPUT);   // Quarter Waxing: 
 pinMode(6, OUTPUT);   // Gibbous Waxing: 
 pinMode(7,OUTPUT);   // Full Moon: 
 pinMode(8, OUTPUT);   // Gibbous Wanning:
 pinMode(9, OUTPUT);   // Quarter Wanning:
 pinMode(10, OUTPUT);  // Crescent Wanning: 
 pinMode(11, OUTPUT);  // Old Wanning: 
 pinMode(13, INPUT);  // Switch 4
 pinMode(12,INPUT);     // Switch 3
 pinMode(1, INPUT);     // Switch 2
 pinMode(0,INPUT);      // Switch 1 

 } void loop() {
 int Reading = digitalRead;
Reading = digitalRead (12); Reading = digitalRead (13);
Reading = digitalRead (1);   Reading = digitalRead (0); 

 if  (digitalRead(0) == HIGH; digitalRead (1)==
   HIGH; digitalRead(12) == HIGH; (digitalRead(13) == HIGH);  { } else 
    {   // loop Full Moon Start   digitalWrite(7, HIGH);  // FULL MOON ON
  delay(5000); 
  digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10);
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);  
 digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000); 
  digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);  
 digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
   digitalWrite(2, HIGH);  // NEW MOON ON
          delay(5000); 
  digitalWrite(2, LOW);   // NEW MOON OFF
          delay(10);  
 digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);  // YOUNG MOON OFF
          delay(100); 
 digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10); 
  digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);  
 digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);

// loop for New moon Reset   if  (digitalRead(0) == LOW;digitalRead (1)==LOW; digitalRead(12) == LOW;(digitalRead(13) ==
    LOW);  
  { } else   // loop New Moon Start
 digitalWrite(2, HIGH);  // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);   // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100);
   digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10);
   digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000); 
  digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10); 
  digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000);
   digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);  // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);
   digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10);
   digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);
   digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
 { } else  { // Young moon Reset Start 
 if  (digitalRead(0) == LOW; digitalRead (1)==LOW; digitalRead(12) ==
    LOW;(digitalRead(13) == HIGH;
 )
   { } else  // loop New Moon Start
         digitalWrite(3, HIGH);
  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100); 
  digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000); 
  digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10);
   digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000); 
  digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10); 
  digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10); 
 digitalWrite(7, HIGH);    // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000); 
  digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);  
 digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000); 
  digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
         digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);       // NEW MOON OFF
          delay(10);
  } 
 // Waxing Crescent Reset Start if  (digitalRead(0) == LOW; digitalRead (1)== LOW; digitalRead(12) ==
    HIGH; digitalRead(13) == HIGH;)    { } else  // Waxing Crescent Moon
    reset Start
  digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000);
   digitalWrite(4, LOW);    // WAX CRESCENT MOON OFF
          delay(10); 
 digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);
   digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);    // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10);  
  digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000);
   digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10);  
 digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000);   digitalWrite(11, LOW);      // OLD MOON OFF
         delay(5000);
   digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000);
   digitalWrite(2, LOW);      // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);       // YOUNG MOON OFF
          delay(100);
  } 
  // First Quarter Moon Reset if  (digitalRead(0) == LOW; digitalRead(1) == HIGH; digitalRead(12) ==
    HIGH; digitalRead(13) == HIGH;)   { else  {
  //FIRST QUARTER  Moon
    reset Start
digitalWrite(5, HIGH);   // FIRST QUARTER ON
          delay(5000);
   digitalWrite(5, LOW);     // FIRST CRESCENT OFF  
          delay(10);
   digitalWrite(6, HIGH);   // WAX GIBBOUS ON
         delay(5000); 
  digitalWrite(6, LOW);    // WAX GIBBOUS OFF
          delay(10);
  digitalWrite(7, HIGH);  // FULL MOON ON
        delay(5000);
   digitalWrite(7, LOW);    // FULL MOON OFF
        delay(10); 
   digitalWrite(8,HIGH);   // WAN GIBBOUS MOON ON
        delay(5000); 
  digitalWrite(8, LOW);    // WAN GIBBOUS MOON OFF
          delay(10); 
  digitalWrite(9, HIGH);   // 3RD QUARTER MOON ON
          delay(5000);
   digitalWrite(9, LOW);     // 3RD QUARTER MOON OFF
          delay(10); 
  digitalWrite(10, HIGH);    // WAN CRESENT MOON ON
         delay(5000);
   digitalWrite(10, LOW);     // WAN CRESENT MOON OFF
          delay(10); 
  digitalWrite(11, HIGH);     // OLD MOON ON
         delay(5000); 
  digitalWrite(11, LOW);      // OLD MOON OFF
          delay(5000); 
  digitalWrite(2, HIGH);   // NEW MOON ON
          delay(5000); 
  digitalWrite(2, LOW);    // NEW MOON OFF
          delay(10);
   digitalWrite(3, HIGH);  // YOUNG MOON ON
          delay(5000);
   digitalWrite(3, LOW);    // YOUNG MOON OFF
          delay(100);
   digitalWrite(4, HIGH);   // WAX CRESCENT MOON ON
         delay(5000); 
  digitalWrite(4, LOW);        // WAX CRESCENT MOON OFF
          delay(10); 
 } 
// code would continue with other loops. Thanks for looking at  my 16 RESET problem, email me. Any suggestions would be appreciated
</code></pre>
 20533: <p>a skeleton solution:</p>

<pre><code>int in[] = {0,1,12,13};
int out[] = {2,3,4,5,6,7,8,9,10,11};
...
void setup()
{
    for(int i=0; i &lt; 4; i++)
        pinMode(in[i], INPUT)

    for(int i=0; i &lt; 10; i++)
        pinMode(out[i], OUTPUT)
}
...
void do0 {...};
void do1 {...};
void do2 {...};
void do3 {...};
void do4 {...};
void do5 {...};
void do6 {...};
void do7 {...};
void do8 {...};
void do9 {...};
void do10 {...};
void do11 {...};
void do12 {...};
void do13 {...};
void do14 {...};
void do15 {...};
...
void loop()
{
    int addr = 0;
    for(int i=0; i&lt;4; i++)
       addr |= digitalRead(in[i]) &lt;&lt; i;

    switch(addr)
    {
    case 0:
       do0();
       break;
    case 1:
       do1();
       break;
    case 2:
       do2();
       break;
    case 3:
       do3();
       break;
    case 4:
       do4();
       break;
    case 5:
       do5();
       break;
    case 6:
       do6();
       break;
    case 7:
       do7();
       break;
    case 8:
       do8();
       break;
    case 9:
       do9();
       break;
    case 10:
       do10();
       break;
    case 11:
       do11();
       break;
    case 12:
       do12();
       break;
    case 13:
       do13();
       break;
    case 14:
       do14();
       break;
    case 15:
       do15();
       break;
    }
}
</code></pre>
 7508: <p>This may be a little too advanced for the OP but... reading esoterik’s
answer, I couldn't help the urge to transform that big switch/case into
an array lookup. Admittedly, the syntax for declaring the array of
function pointers is a little bit esoteric. ;-)</p>



<pre class="lang-c++ prettyprint-override"><code>void loop()
{
    // List of implemented behaviors.
    static void (* const behaviors[])() = {
        do0, do1, do2,  do3,  do4,  do5,  do6,  do7,
        do8, do9, do10, do11, do12, do13, do14, do15
    };

    // Build the index of the requested behavior.
    int addr = 0;
    for (int i = 0; i &lt; 4; i++)
       addr |= digitalRead(in[i]) &lt;&lt; i;

    // Now do it.
    behaviors[addr]();
}
</code></pre>

<hr>

<p><strong>Edit</strong>: To address the OP's issue. I may have missed something, but it
looks to me like all the cases do the exact same thing: loop through the
outputs, turn each one on, wait 5 seconds, then turn it off. The only
difference between the cases is the index of the output that is turned
on first. In this case, all this repetitive code can be factored into a
single loop as follows:</p>

<pre class="lang-c++ prettyprint-override"><code>// Turn on then off all the outputs in turn,
// starting from the given index.
void loop_outputs(int start_index)
{
    int index = start_index;
    for (int count = 0; count &lt; 10; count++) {

        // Light up that LED for 5 s.
        digitalWrite(out[index], HIGH);
        delay(5000);
        digitalWrite(out[index], LOW);
        delay(10);

        // Go to the next one, wrapping index 10 -&gt; 0.
        if (++index == 10) index = 0;
    }
}
</code></pre>
