What is the type of "pin" in pinMode()

In a situation as:

int arr[]={1,2,3};

void setup() { pinMode(arr, OUTPUT); }

it looks like the use of arr[] variable is incorrect. Yet, it works.

So, what exactly is the type of "pin" that enables this. Are there any side effects of such an unconventional syntax?


sketch_dec17a:5: error: invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]

     pinMode(arr, OUTPUT);


In file included from C:\Users\CROSSR~1.CRO\AppData\Local\Temp\build29d1efb85da66b5c654cc9d12bbd8e02.tmp\sketch\sketch_dec17a.ino.cpp:1:0:

C:\Arduino 1.6.9\hardware\arduino\avr\cores\arduino/Arduino.h:125:6: error:   initializing argument 1 of 'void pinMode(uint8_t, uint8_t)' [-fpermissive]

 void pinMode(uint8_t, uint8_t);


exit status 1
invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]

That doesn't compile. You need array syntax:

pinMode(arr[0], OUTPUT); pinMode(arr[1], OUTPUT); pinMode(arr[2], OUTPUT);

Doesn't need to be int, can be byte as pin numbers will always be in the range 0 to 255.

No, it does NOT "work". It may compile but it will most certainly NOT work. "arr" resolves to the memory address of the first element of the array, which is a meaningless thing to pass as an argument to pinMode.

The pin number is some kind of integer. The exact type is, in most cases, not terribly important, as the compiler will cast the argument to the correct size integer type. But passing an array address as you are doing will accomplish nothing of value.

Regards, Ry L.

civgmh: Are there any side effects of such an unconventional syntax?

Yes - there is a small side effects - your pins won't be set as output. As Arduino (Atmega) pins default to inputs, that could actually be considered a bug by some old generation picky programmers who like things when they work..Now if you don't use the pins in the code or use them as input, then you'll be fine.

Suggest you stick to conventional syntax :)

void pinMode(uint8_t pin, uint8_t mode);