Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: Set pinMode via const array for pin numbers?

  1. #1
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Isle in the Salish Sea

    Set pinMode via const array for pin numbers? (sorted sort of)

    const int SO_PINS[4] = {12,1,2,3}; //array size is (M_PINS)^-2
    void setup() {
        pinMode(SO_PINS[0], OUTPUT);
        //pinMode(12, OUTPUT);
    void loop() {
    Is there a reason this will not work for me?
    If I use the commented line instead it works fine.

    To test I have a current-limited LED sourced by PIN12.

    I was hoping to initialize a set of pins as OUTPUT with a loop. When it didn't work I determined it was not the loop but trying to read the constant array value that was failing.

    Anyone have insight on this for me?

    EDIT - I swear I tested this a dozen times before posting but on the first test after posting it's suddenly is working... :S
    Last edited by oddson; 10-22-2017 at 08:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts