title: Is it possible to put if statement with AND comparison into statement or for loop
body: <p>I am writing a piece of code in the Arduino IDE. I have an IF statement which has a long comparison of arrays to see if they are all equal to 0. If they are then carry out the code within the statement.</p>
  
  <p>I'm not sure if this is possible but thought I would ask if the code can be simplified. For all the other code I have been able to use for loops, but I cannot see this working with this statement.</p>
  
  <p>The statement will have about 20 arrays to compare in the end.</p>
  
  <pre><code>if (Tbit[0] == 0 &amp;&amp; Tbit[1] == 0 &amp;&amp; Tbit[2] == 0 &amp;&amp; Tbit[3] == 0){
    digitalWrite(Tout[0], HIGH);
    digitalWrite(Tout[1], HIGH);
  }
  </code></pre>
  
  <p><strong>EDIT UPDATE</strong></p>
  
  <p>I have tried PiNaKa30 suggestion below which I thought would work but still the outputs for the HIGH statement are not being carried out. Below is the full void loop code with my code above commented out and PiNaKa30 codes added.</p>
  
  <p>The bit being read at the beginning only goes HIGH '1' for 1 second when a command input to the arduino is received. Normal state is 0</p>
  
  <pre><code>    void loop() {
      cmri.process();
      for (int i=0; i&lt;2; i++){
         Tbit[i] = (cmri.get_bit(i));
      }
  
      for (int i=0; i&lt;2; i++){
        if (Tbit[i] == 1){
           digitalWrite(Tout[i], !Tbit[i]);
        }
      }
  
    //  if (Tbit[0] == 0 &amp;&amp; Tbit[1] == 0){
     //   digitalWrite(Tout[0], HIGH);
    //    digitalWrite(Tout[1], HIGH);
    //  }
  
  
      for(int i=0; i &lt; 2; i++){
        val = val || Tbit[i];    // Even a single 1 in Tbit will make val=1
      }
  
      if(val == 0){
        digitalWrite(Tout[0], HIGH);
        digitalWrite(Tout[1], HIGH);
      }
  }
  </code></pre>