# Understanding pin definitions to write Arduino code

**URL:** <https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693>\
**Category:** Artemis\
**Created:** [November 8, 2022, 9:20pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693 "2022-11-08T21:20:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewpw](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@matthewpw](https://community.sparkfun.com/u/matthewpw)\
**Post date:** [November 8, 2022, 9:20pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/1 "2022-11-08T21:20:09Z")

</div>

Hello!

I’m a beginner and struggling pin definitions in Arduino. paulvha started to set me straight over here: [viewtopic.php?f=169&t=58525](https://forum.sparkfun.com/viewtopic.php?f=169&t=58525) but I’m moving on to adding buttons to my project and I’m clearly not getting it. I’m looking at the Schematic, Apollo3 Datasheet, and Integrations Guide here: [https://www.sparkfun.com/products/15443](https://www.sparkfun.com/products/15443).

When I connect a switch to the pin labelled 13 on the board, the following code works:

```auto
int soundOut = A16;
int buttonOne = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(soundOut, OUTPUT);
  pinMode(buttonOne, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:
    if (digitalRead(buttonOne) == LOW){
      tone(soundOut, 440, 100);
      delay(100);
      tone(soundOut, 880, 100);
      delay(100);
    }
  }

```

If I wanted to use pin A14 instead, what would that look like?

I obviously don’t understand the difference between the AX pins and the X pins or how to configure them. What can each of them be and how do I make them so?

Thanks in advance.

-M

---

<div class="post-metadata">

**Author:** ![matthewpw](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@matthewpw](https://community.sparkfun.com/u/matthewpw)\
**Post date:** [November 8, 2022, 9:58pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/2 "2022-11-08T21:58:42Z")

</div>

I’m finding this forum which I also can’t entirely parse: [viewtopic.php?f=169&t=57715](https://forum.sparkfun.com/viewtopic.php?f=169&t=57715).

I don’t need to dynamically assign any pins — hadn’t gotten far enough to consider it, really. I’m looking around for tutorials that cover addressing pins more generally but I’m not finding much right off the bat. Pointers to good learning resources on this topic are welcome!

---

<div class="post-metadata">

**Author:** ![jremington](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/jremington/32/6595_2.png) [@jremington](https://community.sparkfun.com/u/jremington)\
**Post date:** [November 8, 2022, 11:53pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/3 "2022-11-08T23:53:58Z")

</div>

Please state the exact board are you using.

In any case, look for a complete pinout guide, published for most of the popular boards. Next to each pin is an abbreviated description summarizing that pin’s various capabilities.

Most of the pins with “A” labels can be used as either analog input or digital I/O, the ones labeled with decimal digits are digital I/O only.

> Pointers to good learning resources on this topic are welcome!

If you are using the Arduino IDE to program, ALWAYS consult the Arduino Reference: [https://www.arduino.cc/reference/en/](https://www.arduino.cc/reference/en/)

Example pinout for the classic Arduino Uno:

 ![Capture.PNG](https://canada1.discourse-cdn.com/sparkfun/original/3X/7/9/79195a925b5c9a9ad46bd4fbaf88803fc5451dda.png)

---

<div class="post-metadata">

**Author:** ![matthewpw](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@matthewpw](https://community.sparkfun.com/u/matthewpw)\
**Post date:** [November 9, 2022, 12:46am UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/4 "2022-11-09T00:46:02Z")

</div>

Thanks @jremington.

You’ve put your finger exactly on it. I thought the AX pins could still be used for digital but I can’t make code that will work with them for the switch input. It’s got to be simple and I’m just dense.

What code adjustment do I need to use the A14 pin, for example on the Artemis Nano? I apologize for not naming the board explicitly, but that’s where the product/doc link in my post lands and is the reason I’m posting in an Artemis forum. The Android forums are also helpful but no one there seems to know how to use the Artemis boards.

I am referencing the Arduino documentation you link to. It’s well made and makes sense to me, generally, but doesn’t give insight into how to address the Artemis Nano. I have a much harder time with the Artemis docs than the example diagram you’ve posted here. There’s lots available on the UNO and maybe I should just switch boards but the form factor and cost of the Artemis Nano — as well as benefit for understanding it well to do more complicated projects in the future — are the draw.

In the meantime I found some good guides on using registers but all of those examples are for Arudino Uno and I’m also not doing a good job of understanding of how to read the Artemis Nano docs to understand it similarly.

---

<div class="post-metadata">

**Author:** ![jremington](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/jremington/32/6595_2.png) [@jremington](https://community.sparkfun.com/u/jremington)\
**Post date:** [November 9, 2022, 4:43am UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/5 "2022-11-09T04:43:19Z")

</div>

I looked through the material for a pinout diagram for the Artemis Nano and could not find one. Or a table. It looks like Sparkfun has not done a great job of documenting the precise capabilities of the various pins on the Artemis Nano. Perhaps one of the developers can chime in here. Or you could post an issue on the Github site.

Checking the schematic, the pin labeled A14 has several alternative digital functions (see image below), so in principle it can be used as general digital I/O. However, the Arduino IDE has a lookup table specific to each board that specifies the allowed pin functions, and whoever created that table may not have provided a path for using the pin as digital I/O.

To address your problem, several pins on the right side of the schematic have labels beginning with “D” e.g. 4,6-13 and a couple of others, so try using one of those for digital I/O instead.

Some Arduinos do have “analog only” pins, and in those cases you simply have to be aware of the exceptions to the rule.

 ![artemis_nano.PNG](https://canada1.discourse-cdn.com/sparkfun/original/3X/2/8/2874e9c8ccb093fbc0bd82038dbdcfb40086ad17.png)

---

<div class="post-metadata">

**Author:** ![paulvha](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@paulvha](https://community.sparkfun.com/u/paulvha)\
**Post date:** [November 9, 2022, 2:02pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/6 "2022-11-09T14:02:43Z")

</div>

Looks indeed this is missing, but Actually for the Nano is very straightforward:

```auto
On BOARD	PinName
4 D4
6 D6
7 D7
8 D8
9 D9
10 D10
11 D11
12 D12
13 D13
A16 A16 or D16
A15 A15 or D15
A14 A14 or D14
A5 A5 or D5
A3 A3 or D3
A2 A2 or D2
A1 A1 or D1
A0 A0 or D0

```

So 13 is D13

---

<div class="post-metadata">

**Author:** ![jremington](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/jremington/32/6595_2.png) [@jremington](https://community.sparkfun.com/u/jremington)\
**Post date:** [November 9, 2022, 3:38pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/7 "2022-11-09T15:38:11Z")

</div>

Thanks, Paul. But the table still seems incomplete.

What does the pin labeled A14 (the subject of this post) do?

---

<div class="post-metadata">

**Author:** ![paulvha](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@paulvha](https://community.sparkfun.com/u/paulvha)\
**Post date:** [November 9, 2022, 4:30pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/8 "2022-11-09T16:30:27Z")

</div>

A14 (like all the A channels on the Nano) support ‘Tone’. So instead of using A16, just define A14 in the sketch for Tone output. For the button use D13

---

<div class="post-metadata">

**Author:** ![matthewpw](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@matthewpw](https://community.sparkfun.com/u/matthewpw)\
**Post date:** [November 11, 2022, 1:47pm UTC](https://community.sparkfun.com/t/understanding-pin-definitions-to-write-arduino-code/44693/9 "2022-11-11T13:47:37Z")

</div>

Thanks, both.
