user16272: I am currently using relay module, but I am facing a problem that, when Arduino pins are LOW then all relay are going HIGH, so I want to use this code so that when arduino starts all pins are getting HIGH, and also can be control with char data/switch(data)/case break;/,
Here is my code:

setup() {
  if(conditionIsTrue) {
    aGroup::setup();
  } else {
    bGroup::setup();    
  }
}

loop() {
  if(conditionIsTrue) {
    aGroup::loop();
  } else {
    bGroup::loop();    
  }
}

namespace aGroup {
setup() {

    pinMode(ledPinA, OUTPUT);
    pinMode(ledPinB, OUTPUT);
    pinMode(ledPinC, OUTPUT);
    pinMode(ledPinD, OUTPUT);
    pinMode(ledPinE, OUTPUT);
    pinMode(ledPinF, OUTPUT);
    pinMode(ledPinG, OUTPUT);
    pinMode(ledPinH, OUTPUT);
    pinMode(ledPinI, OUTPUT);
    pinMode(ledPinJ, OUTPUT);
    pinMode(ledPinK, OUTPUT);
    pinMode(ledPinL, OUTPUT);

}

loop() {

  digitalWrite(ledPinA, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinH, HIGH);
  digitalWrite(ledPinI, HIGH);
  digitalWrite(ledPinJ, HIGH);
  digitalWrite(ledPinK, HIGH);
  digitalWrite(ledPinL, HIGH);

}
}

namespace bGroup {
setup() {
  Serial.begin(9600);
    pinMode(ledPinA, OUTPUT);
    pinMode(ledPinB, OUTPUT);
    pinMode(ledPinC, OUTPUT);
    pinMode(ledPinD, OUTPUT);
    pinMode(ledPinE, OUTPUT);
    pinMode(ledPinF, OUTPUT);
    pinMode(ledPinG, OUTPUT);
    pinMode(ledPinH, OUTPUT);
    pinMode(ledPinI, OUTPUT);
    pinMode(ledPinJ, OUTPUT);
    pinMode(ledPinK, OUTPUT);
    pinMode(ledPinL, OUTPUT);

}

loop() {

  char data = Serial.read();
    switch(data) 
    {
        case 'A': digitalWrite(ledPinA, HIGH);break;
        case 'B': digitalWrite(ledPinA, LOW);break;

        case 'C': digitalWrite(ledPinB, HIGH);break;
        case 'D': digitalWrite(ledPinB, LOW);break;

        case 'E': digitalWrite(ledPinC, HIGH);break;
        case 'F': digitalWrite(ledPinC, LOW);break;

        case 'G': digitalWrite(ledPinD, HIGH);break;
        case 'H': digitalWrite(ledPinD, LOW);break;

        case 'I': digitalWrite(ledPinE, HIGH);break;
        case 'J': digitalWrite(ledPinE, LOW);break;

        case 'K': digitalWrite(ledPinF, HIGH);break;
        case 'L': digitalWrite(ledPinF, LOW);break;

        case 'M': digitalWrite(ledPinG, HIGH);break;
        case 'N': digitalWrite(ledPinG, LOW);break;

        case 'O': digitalWrite(ledPinH, HIGH);break;
        case 'P': digitalWrite(ledPinH, LOW);break;

        case 'Q': digitalWrite(ledPinI, HIGH);break;
        case 'R': digitalWrite(ledPinI, LOW);break;

        case 'S': digitalWrite(ledPinJ, HIGH);break;
        case 'T': digitalWrite(ledPinJ, LOW);break;

        case 'U': digitalWrite(ledPinK, HIGH);break;
        case 'V': digitalWrite(ledPinK, LOW);break;

        case 'W': digitalWrite(ledPinL, HIGH);break;
        case 'X': digitalWrite(ledPinL, LOW);break;


    }

}
}

But this isn't work, Please help me.

user30002: In first place, you have to declare the functions setup and loop as void setup() and void loop().
If you want your output pins to be high when Arduino starts then you should do that in your setup function, instead of doing it in the loop:
void setup() {

  Serial.begin(9600);

  // Step 1: configure pins as outputs
  pinMode(ledPinA, OUTPUT);
  pinMode(ledPinB, OUTPUT);
  pinMode(ledPinC, OUTPUT);
  pinMode(ledPinD, OUTPUT);
  pinMode(ledPinE, OUTPUT);
  pinMode(ledPinF, OUTPUT);
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinH, OUTPUT);
  pinMode(ledPinI, OUTPUT);
  pinMode(ledPinJ, OUTPUT);
  pinMode(ledPinK, OUTPUT);
  pinMode(ledPinL, OUTPUT);

  // Step 2: initialize pins to output HIGH
  digitalWrite(ledPinA, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinH, HIGH);
  digitalWrite(ledPinI, HIGH);
  digitalWrite(ledPinJ, HIGH);
  digitalWrite(ledPinK, HIGH);
  digitalWrite(ledPinL, HIGH);
}

Also, you can't declare a variable and assign to it the value of a function other than an object constructor. Furthermore, you should check if there's data available before trying to read it. So you have replace the following sentence:
char data = Serial.read();

With something like this:
char data = 0;
if (Serial.available() > 0) {
    data = Serial.read();
    // do your stuff
}

This should do the trick.
Last but not least: I don't know why you're using two namespaces. The aGroup looks useless to me. On top of that, I fail to see where in your code do you declare, initialise and update the conditionIsTrue variable. The same goes for all those ledPinX variables. Is there more code that you're not showing here? Is your code failing at runtime, or doesn't even compile?

16272: <p>I am currently using relay module, but I am facing a problem that, when Arduino pins are LOW then all relay are going HIGH, so I want to use this code so that when arduino starts all pins are getting HIGH, and also can be control with char data/switch(data)/case break;/,</p>

<pre><code>Here is my code:

setup() {
  if(conditionIsTrue) {
    aGroup::setup();
  } else {
    bGroup::setup();    
  }
}

loop() {
  if(conditionIsTrue) {
    aGroup::loop();
  } else {
    bGroup::loop();    
  }
}

namespace aGroup {
setup() {

    pinMode(ledPinA, OUTPUT);
    pinMode(ledPinB, OUTPUT);
    pinMode(ledPinC, OUTPUT);
    pinMode(ledPinD, OUTPUT);
    pinMode(ledPinE, OUTPUT);
    pinMode(ledPinF, OUTPUT);
    pinMode(ledPinG, OUTPUT);
    pinMode(ledPinH, OUTPUT);
    pinMode(ledPinI, OUTPUT);
    pinMode(ledPinJ, OUTPUT);
    pinMode(ledPinK, OUTPUT);
    pinMode(ledPinL, OUTPUT);

}

loop() {

  digitalWrite(ledPinA, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinH, HIGH);
  digitalWrite(ledPinI, HIGH);
  digitalWrite(ledPinJ, HIGH);
  digitalWrite(ledPinK, HIGH);
  digitalWrite(ledPinL, HIGH);

}
}

namespace bGroup {
setup() {
  Serial.begin(9600);
    pinMode(ledPinA, OUTPUT);
    pinMode(ledPinB, OUTPUT);
    pinMode(ledPinC, OUTPUT);
    pinMode(ledPinD, OUTPUT);
    pinMode(ledPinE, OUTPUT);
    pinMode(ledPinF, OUTPUT);
    pinMode(ledPinG, OUTPUT);
    pinMode(ledPinH, OUTPUT);
    pinMode(ledPinI, OUTPUT);
    pinMode(ledPinJ, OUTPUT);
    pinMode(ledPinK, OUTPUT);
    pinMode(ledPinL, OUTPUT);

}

loop() {

  char data = Serial.read();
    switch(data) 
    {
        case 'A': digitalWrite(ledPinA, HIGH);break;
        case 'B': digitalWrite(ledPinA, LOW);break;

        case 'C': digitalWrite(ledPinB, HIGH);break;
        case 'D': digitalWrite(ledPinB, LOW);break;

        case 'E': digitalWrite(ledPinC, HIGH);break;
        case 'F': digitalWrite(ledPinC, LOW);break;

        case 'G': digitalWrite(ledPinD, HIGH);break;
        case 'H': digitalWrite(ledPinD, LOW);break;

        case 'I': digitalWrite(ledPinE, HIGH);break;
        case 'J': digitalWrite(ledPinE, LOW);break;

        case 'K': digitalWrite(ledPinF, HIGH);break;
        case 'L': digitalWrite(ledPinF, LOW);break;

        case 'M': digitalWrite(ledPinG, HIGH);break;
        case 'N': digitalWrite(ledPinG, LOW);break;

        case 'O': digitalWrite(ledPinH, HIGH);break;
        case 'P': digitalWrite(ledPinH, LOW);break;

        case 'Q': digitalWrite(ledPinI, HIGH);break;
        case 'R': digitalWrite(ledPinI, LOW);break;

        case 'S': digitalWrite(ledPinJ, HIGH);break;
        case 'T': digitalWrite(ledPinJ, LOW);break;

        case 'U': digitalWrite(ledPinK, HIGH);break;
        case 'V': digitalWrite(ledPinK, LOW);break;

        case 'W': digitalWrite(ledPinL, HIGH);break;
        case 'X': digitalWrite(ledPinL, LOW);break;


    }

}
}
</code></pre>

<p>But this isn't work, Please help me.</p>
 30002: <p>In first place, you have to declare the functions setup and loop as <code>void setup()</code> and <code>void loop()</code>.</p>

<p>If you want your output pins to be high when Arduino starts then you should do that in your setup function, instead of doing it in the loop:</p>

<pre><code>void setup() {

  Serial.begin(9600);

  // Step 1: configure pins as outputs
  pinMode(ledPinA, OUTPUT);
  pinMode(ledPinB, OUTPUT);
  pinMode(ledPinC, OUTPUT);
  pinMode(ledPinD, OUTPUT);
  pinMode(ledPinE, OUTPUT);
  pinMode(ledPinF, OUTPUT);
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinH, OUTPUT);
  pinMode(ledPinI, OUTPUT);
  pinMode(ledPinJ, OUTPUT);
  pinMode(ledPinK, OUTPUT);
  pinMode(ledPinL, OUTPUT);

  // Step 2: initialize pins to output HIGH
  digitalWrite(ledPinA, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinH, HIGH);
  digitalWrite(ledPinI, HIGH);
  digitalWrite(ledPinJ, HIGH);
  digitalWrite(ledPinK, HIGH);
  digitalWrite(ledPinL, HIGH);
}
</code></pre>

<p>Also, you can't declare a variable and assign to it the value of a function other than an object constructor. Furthermore, you should check if there's data available before trying to read it. So you have replace the following sentence:</p>

<pre><code>char data = Serial.read();
</code></pre>

<p>With something like this:</p>

<pre><code>char data = 0;
if (Serial.available() &gt; 0) {
    data = Serial.read();
    // do your stuff
}
</code></pre>

<p>This should do the trick.</p>

<p>Last but not least: I don't know why you're using two <code>namespace</code>s. The <code>aGroup</code> looks useless to me. On top of that, I fail to see where in your code do you declare, initialise and update the <code>conditionIsTrue</code> variable. The same goes for all those <code>ledPinX</code> variables. Is there more code that you're not showing here? Is your code failing at runtime, or doesn't even compile?</p>
