All avaiable pins on Arduino array/define

Hi,

I'm curious if there is an array of all avaiable pins on current board as array/definition. I'm looking for it because i got array of all pins my project is using and i want to pull all other pins to vcc to eliminate all floating pins and i dont want to duplicate such array if it exists.

What Arduino board are you using?

On an Uno for example the digital pins are numbered 0 to 13 and the analog pins are normally referred to as A0 to A5. However you can also refer to the analog pins as 14 to 19. In other words, you can iterate over all of them with something like

for (byte n = 0; n <= 19; n++) {


}

If that does not help please explain in more detail what you want to do.

…R

for (pin=0; pin < NUM_DIGITIAL_PINS; i++) {
  // stuff.
}

westfw:

for (pin=0; pin < NUM_DIGITIAL_PINS; i++) {

// stuff.
}

Does it include analog pins too as i want to pull them too?

NUM_DIGITIAL_PINS ?

I need to loop through analog pins too and i'm pretty sure NUM_DIGITAL_PINS doesn't include them but i think there is a NUM_ANALOG_INPUTS to use.

What is actually A1 a definition, enum or something else as i don't know if i can cast loop iterator to get it?

@edit Seems like NUM_DIGITAL_PINS include analogs too and they can be reffered at 53-69 when using arduino mega

Analog pins are digital pins in the first place. NUM_DIGITAL_PINS includes the "analog" pins. For example, on an UNO, NUM_DIGITAL_PINS is 20, and A0-A5 are pin numbers 14-19.

On a Nano, there are two analog-only pins A6-A7. You cannot pull them to VCC because they don't have digital circuitry like the other pins.

Pieter

akimata:
I need to loop through analog pins too

I guess you did not read Reply #1 ?

...R

Come to think of it, Robin's post (with "19" as the destination, or whatever your particular board has as user pins) is probably a better idea.
NUM_DIGITAL_PINS is defined in one of the variant files, and should be "correct" on all boards, but on some boards it may include "internal" connections that you don't want to mess with.