Microcontroller Pin Functions

Introduction

This page explains the basic pin functions that most microcontrollers share, and offers some tips for switching from one microcontroller to another. Since the tutorials on this site are all written with the Arduino Uno in mind, and students may be using other controllers, you may need to know how to “convert” a tutorial from the controller it’s written for to your own controller. In order to get the most out of it, you should know something about electrical circuits, and what a microcontroller is and what it can do. This video might help: Hardware functions in a microcontroller

What Do All These Pins Do?

A typical microcontroller can have between 6 and 60 pins on it, to which you’re expected to attach power connections, input and output connections, and communications connections. Every microcontroller has different configurations for its pins, and often one pin will have more than one function. This combining of functions on one pin is called pin multiplexing.

Every microcontroller has names for the pins specific to its hardware, but the Arduino  application programming interface (API) provides a set of names  for pins and their functions that should work across all microcontrollers that are programmable with the API. So, for example, A0 will always be the analog input pin 0, whether you’re on an Uno, 101, MKRZero, MKR1000, or other Arduino-compatible board. When you connect to the pin with the same function on another board, your code should operate the same, even though the physical layout of pins is different.

Every board has an operating voltage that affects its pins as well. The operating voltage, which is the same as the voltage of the GPIO pins, is labeled below. If you’re connecting a component to a board with a lower voltage than the component, you’ll need to do some level shifting.

Pin Diagrams

Microcontrollers typically come in a variety of physical forms, or packages. Sparkfun has a nice tutorial on integrated circuit package types if you want to know more. Pin numbering on any integrated circuit, including microcontrollers, starts at top left corner, which is usually marked with a dot. From there, you count around the chip counter-clockwise. For modules like the Arduino Uno, this numbering doesn’t hold up, since the board has several pin headers. The pin headers are usually numbered, and the pins of each header are counted. Unfortunately, header numbering does not always follow the same patterns as IC numbering.

Arduino Uno

Here’s a diagram of how the Arduino Uno’s pins are multiplexed. A text chart of this diagram follows the image:

Pin diagram of the Arduino Uno, showing which pins perform which functions. A text chart listing the pin functions follows below this image.
Pin diagram of the Arduino Uno, showing which pins perform which functions.

Arduino Uno Pin Chart

A listing of the Arduino Uno's pin functions.
Pin LabelLocationGPIOADCCommunicationPWMInterruptPowerOther
unlabeledUpper left header, pin 1No connection
Upper left header, pin 2IO Reference Voltage (+5V)
ResetUpper left header, pin 3Program reset
3.3VUpper left header, pin 4+3.3V regulated output
5VUpper left header, pin 5+5V regulated output
GNDUpper left header, pin 6Ground
GNDUpper left header, pin 7Ground
VinUpper left header, pin 8+Voltage in. Unregulated. Outputs whatever voltage is plugged in the DC power jack. Vin: 7-12V DC max.
A0Lower left header, pin 1140
A1Lower left header, pin 2151
A2Lower left header, pin 3162
A3Lower left header, pin 4173
A4Lower left header, pin 5184I2C SDA
A5Lower left header, pin 6195I2C SCL
RX 0Lower right header, pin 80UART Receive
TX 1Lower right header, pin 71UART Transmit
2Lower right header, pin 620
3Lower right header, pin 5331
4Lower right header, pin 44
5Lower right header, pin 355
6Lower right header, pin 266
7Lower right header, pin 17
8Upper right header, pin 108
9Upper right header, pin 999
10Upper right header, pin 810SPI CS10
11Upper right header, pin 711SPI MOSI11
12Upper right header, pin 612SPI MISO
13Upper right header, pin 513SPI SCKBuilt in LED
GNDUpper right header, pin 4Ground
AREFUpper right header, pin 3Analog Reference input
SDAUpper right header, pin 218I2C SDA
SCLUpper right header, pin 119I2C SCL
ICSPBottom center header, pin 1 (top right)SPI MISO
Bottom center header, pin 2 (bottom right)+5V
Bottom center header, pin 3 (top center)SPI SCK
Bottom center header, pin 4 (bottom center)SPI MOSI
Bottom center header, pin 5 (top left)Reset
Bottom center header, pin 6 (bottom left)GNDGround
Upper right inner header, pin 1 (bottom right)SPI MISO for 16U2
Upper right inner header, pin 2 (bottom left)+5V+5V
Upper right inner header, pin 3 (middle right)SPI SCK for 16U2
Upper right inner header, pin 4 (middle left)SPI MOSI for 16U2
Upper right inner header, pin 5 (upper right)Reset for 16U2
Upper right inner header, pin 6 (upper left)GNDGround

Notes on the Uno:

  • The Uno has a second microcontroller on board to handle USB-to-serial communications. This is the ICSP header for that microcontroller.
  • Serial: Serial is attached to pins 0 and 1, and to the USB-Serial micrcontroller on board.We’re going to issue a more formal “application note” to explain some of the new features provided by this pin. For now just treat it as one extra pin available for you to use. Enjoy your Arduino Zero

Arduino MKR Series

Here’s the diagram for the Arduino MKR boards, like the MKRZero, MRK1000, and so forth. The pin numbering follows the pattern of a typical integrated circuit as described above; pin 1 is on the top left, and pin 28 is on the top right:

Pin diagram of the Arduino MKR-format boards. See the text chart below for a full listing of the pins.
Pin diagram of the Arduino MKR-format boards.

Arduino MKR Series Pin Chart

A listing of the Arduino MKR series' pin functions.
Pin LabelLocationGPIOADCCommunicationPWMInterruptPowerOther
AREF1Analog Reference input
DAC0/ADC02150Digital-to-Analog Converter 0
A1316116
A241717
A351818
A461919
A5720
A6821
0900
110111
21122
31233
413444
514555
615666Built-in LED
716777
8178SPI MOSI88
9189SPI SCK
101910SPI MISO10
112011I2C SDA
122112I2C SCL
132213UART TX1
142314UART RX1
RESET24Reset
GND25Ground
Vcc26+3.3V voltage supply
Vin27Unregulated voltage input
+5V28+5V (only active when powered from USB)

Notes on the MKR Series

  • Serial: The MKR1000 has two hardware UARTs.The first one, UART0 (aka Serial in your sketches) is attached directly to the USB port not to any pins. GPIO pins 13 and 14 are Serial1
  • Battery in: LiPo, 3.7V, 700mAh min Recharging circuit on board.

Arduino 101

And here’s the diagram for the Arduino 101:

Pin diagram of the Arduino 101 board. See the text chart below for a full listing of the pins.
Pin diagram for the Arduino 101.

Arduino 101 Pin Chart

A listing of the Arduino 101's pin functions.
Pin LabelLocationGPIOADCCommunicationPWMInterruptPowerOther
ATNUpper left header, pin 1See note below
Upper left header, pin 2IO Reference Voltage (+3.3V)
ResetUpper left header, pin 3Program reset
3.3VUpper left header, pin 4+3.3V regulated output
5VUpper left header, pin 5+5V regulated output
GNDUpper left header, pin 6Ground
GNDUpper left header, pin 7Ground
VinUpper left header, pin 8+Voltage in. Unregulated. Outputs whatever voltage is plugged in the DC power jack. Vin: 7-12V DC max.
A0Lower left header, pin 1140
A1Lower left header, pin 2151
A2Lower left header, pin 3162
A3Lower left header, pin 4173
A4Lower left header, pin 5184I2C SDA
A5Lower left header, pin 6195I2C SCL
RX 1Lower right header, pin 80UART Receive
TX 1Lower right header, pin 71UART Transmit
2Lower right header, pin 62
3Lower right header, pin 533
4Lower right header, pin 44
5Lower right header, pin 355
6Lower right header, pin 266
7Lower right header, pin 17
8Upper right header, pin 108
9Upper right header, pin 999
10Upper right header, pin 810SPI CS
11Upper right header, pin 711SPI MOSI
12Upper right header, pin 612SPI MISO
13Upper right header, pin 513SPI SCKBuilt in LED
GNDUpper right header, pin 4Ground
AREFUpper right header, pin 3Analog Reference input
SDAUpper right header, pin 218I2C SDA
SCLUpper right header, pin 119I2C SCL
ICSPBottom center header, pin 1 (top right)SPI MISO
Bottom center header, pin 2 (bottom right)+3.3V
Bottom center header, pin 3 (top center)SPI SCK
Bottom center header, pin 4 (bottom center)SPI MOSI
Bottom center header, pin 5 (top left)Reset
Bottom center header, pin 6 (bottom left)GNDGround

Notes on the 101

  • Interrupts: All GPIO pins can be used as interrupts for HIGH, LOW, RISING, and FALLING. .Only pins 2, 5, 7, 8, 10, 11, 12, 13 can be used for CHANGE interrupts.
  • Serial: The 101 has two hardware UARTs. Serial is attached directly to the USB port of the 101, not to any pins. GPIO pins 0 and 1 are Serial1
  • The ATN pin: Many shields and expansion modules use SPI communication, this always requires a chip select. On processors that have more than 28 pins there are usually extra unallocated pins that can be used. On the 101, this pin is available.

Arduino Adafruit Feather M0

Finally, here’s the pin diagram for the Adafruit Feather M0 Proto. It should be more or less the same for the other Feather M0 boards, but check the documentation for your board to be sure.

Pin diagram of the Adafruit Feather M0. See the text chart below for a full listing of the pins.
Pin diagram for the Adafruit Feather M0

Adafruit Feather M0 Pin Chart

A listing of the Adafruit Feather M0's pin functions.
Pin LabelLocationGPIOADCCommunicationPWMInterruptPowerOther
Reset1Reset
+3.3V2+3.3V regulated voltage output
AREF3Analog Reference Voltage Input
GND4Ground
A05140Digital-to-Analog Converter 0
A16151
A27162
A3817318
A4918419
A510195
SCK1124SPI SCK
MISO1223SPI MISO
MOSI1322SPI MOSI
RX1140
UART RX1
TX1151UART TX1
GND16Ground
SDA1721I2C SDA
SCL1820I2C SCL
D51955
D6206
D921979Attached to battery input connector, for monitoring battery level
D10221010
D112311
D122412
D132513Built-in LED
+5V26+5V (only active when powered from USB)
En27+3.3V regulator enable
VBat28Unregulated Voltage in

Notes on the Feather M0

  • Serial: The FEATHER M0 has two hardware UARTs. The first one, UART0 (aka Serial in your sketches) is attached directly to the USB port not to any pins. GPIO pins 0 and 1 are UART1, aka Serial1
  • Battery in: LiPo, 3.7V Recharging circuit on board.
  • Vin: 3.7-5V DC max. (USB), 4.2V Max.(Battery)
  • Interrupts: All pins can be interrupt pins.

Pin Functions Explained

In order to make sense of all of this, it helps to know the general functions of a microcontroller. There are a few common functions:

Power:  Every microcontroller will have connections for power (often labeled Vcc, Vdd, or Vin) and ground. A bare microcontroller will have only those, but modules like the Arduino, the Raspberry Pi, and others also have voltage regulators and other components on board. On these, it’s common to see an unregulated voltage input (Vin) and a regulated voltage output (5V and 3.3V on the Uno, for example).

Clock: Every microcontroller needs a clock. The bare microcontroller chip usually has two pins for this. On a module, the clock is usually built onto the board, and the pins are not exposed.

General Purpose Input and Output (GPIO): Most pins on a microcontroller can operate as either a digital input or digital output.

Hardware Interrupts: Many microcontrollers have a subset of their GPIO pins attached to hardware interrupt circuits. A hardware interrupt can interrupt the flow of a program when a given pin changes its state, so you can read it immediately. Some higher level functions like asynchronous serial and PWM sometimes use these interrupts. They’re also good for very responsive reading of digital inputs.

Analog Input (ADC): Not all microcontrollers have an analog-to-digital converter (ADC), but those that do have a number of pins connected to it and act as inputs to the ADC. If there are analog inputs, include analog reference pin as well, that tells the microcontroller what the default high voltage of the ADC is.

Pulse Width Modulation (PWM): Few microcontrollers have a true analog voltage output (though the MKR1000 does), but most have a set of pins connected to an internal oscillator that can produce a pseudo-analog voltage using PWM. This is how the analogWrite() function in Arduino works.

Communications:

Universal Asynchronous Receiver/Transmitter (UART): Asynchronous serial communication is managed by a Universal Asynchronous Receiver/Transmitter, or UART, inside the processor. The UART pins are usually attached to internal hardware interrupts that can interrupt the program flow when new serial data arrives, so you never miss a byte. It’s possible to manage serial communication in software alone, but at high speeds, you’ll see more errors.

Synchronous Serial: SPI and I2C: Most microcontrollers also have dedicated modules in the processor to handle the two most common forms of synchronous serial communication.

The Serial-Peripheral Interface (SPI) bus has four dedicated pins: Master In, Slave Out (MISO); Master Out, Slave In (MOSI); Serial Clock (SCK) and Chip Select (CS). Many miccrocontrollers are programmed via SPI through an In-Circuit Serial Programming header (ICSP) as well.

The Inter-Integrated Circuit (I2C) bus has two pins: Serial Data (SDA) and Serial Clock (SCL).

Reset: All microcontrollers have a pin which resets the program. Usually you take this pin low to reset the controller.

IORef: this is the operating voltage of the board. The Uno and 101 have this pin so that shields can read this voltage to adjust their own output voltages as needed. Not all shields have this functionality.

Originally written on August 26, 2016 by Tom Igoe
Last modified on August 20, 2018 by Tom Igoe