user7806: I notice problems with my output pins when I use this method of setting their pinMode:
int allOutputPins[] = {3, 4, 9, 10, 5, A3, 11, 12, 7, 8, A1, A2};


for(int a = 0; a < sizeof(allOutputPins); a++){
   pinMode(allOutputPins[a], OUTPUT); 
  }//end for

Am I doing something wrong?

user3917: Re  “Am I doing something wrong?”, yes :)
The sizeof(allOutputPins) expression returns the size of allOutputPins[] in terms of bytes, so is 24 because the array contains 12 two-byte integers.  The loop's last 12 pinMode() calls will be garbage.
Among other ways of fixing the problem, you could change the expression to sizeof(allOutputPins)/sizeof(int) [which has the same value, 12, as (sizeof allOutputPins)/sizeof(int); eg see the syntax entries for the sizeof operator at cppreference.com] or you could change the base type of the array to byte or uint8_t.

7806: <p>I notice problems with my output pins when I use this method of setting their <code>pinMode</code>:</p>

<pre><code>int allOutputPins[] = {3, 4, 9, 10, 5, A3, 11, 12, 7, 8, A1, A2};


for(int a = 0; a &lt; sizeof(allOutputPins); a++){
   pinMode(allOutputPins[a], OUTPUT); 
  }//end for
</code></pre>

<p>Am I doing something wrong?</p>
 3917: <p>Re  “Am I doing something wrong?”, yes :)</p>

<p>The <code>sizeof(allOutputPins)</code> expression returns the size of <code>allOutputPins[]</code> in terms of bytes, so is 24 because the array contains 12 two-byte integers.  The loop's last 12 <code>pinMode()</code> calls will be garbage.</p>

<p>Among other ways of fixing the problem, you could change the expression to <code>sizeof(allOutputPins)/sizeof(int)</code> [which has the same value, 12, as <code>(sizeof allOutputPins)/sizeof(int)</code>; eg see the syntax entries for the <a href="http://en.cppreference.com/w/cpp/language/sizeof" rel="nofollow">sizeof operator</a> at cppreference.com] or you could change the base type of the array to <code>byte</code> or <code>uint8_t</code>.</p>
