Board Pins

To use digital I/O you need to learn how to access the pins on your board. These are the physical points where you connect wires to access the digital signals. On some boards, like Metro M0 Express, the digital I/O pins are exposed with female headers that work well with breadboard-friendly hookup wires. On other boards like Circuit Playground Express and Gemma M0 the digital I/O pins are large copper pads with holes that are easy to connect to alligator clips or conductive thread. Check your board’s documentation to see where all of the digital I/O pins are located.

In CircuitPython you use the board module to reference digital I/O pins. The board module contains an object for each pin on the board and they’re typically named after labels on the board. You can list all of the pins in the board module with Python’s dir function, for example from a board’s REPL run:

Download: file
>>> import board
>>> dir(board)
['A0', 'SPEAKER', 'A1', 'A2', 'A3', 'A4', 'SCL', 'A5', 'SDA', 'A6', 'RX',
'A7', 'TX', 'LIGHT', 'A8', 'TEMPERATURE', 'A9', 'BUTTON_A', 'D4', 'BUTTON_B',
'D5', 'SLIDE_SWITCH', 'D7', 'NEOPIXEL', 'D8', 'D13', 'REMOTEIN', 'IR_RX',
'REMOTEOUT', 'IR_TX', 'IR_PROXIMITY', 'MICROPHONE_SCK', 'MICROPHONE_DO',
'ACCELEROMETER_INTERRUPT', 'ACCELEROMETER_SDA', 'ACCELEROMETER_SCL',
'SPEAKER_ENABLE', 'SCK', 'MOSI', 'MISO', 'FLASH_CS']

Each of the objects returned by the dir command represents a named pin on the board. Above you see the output on a Circuit Playground Express board which has pins like A0, A1, D4, D5, etc. that represent pins that run around the diameter of the board. There are even named pins like BUTTON_A, BUTTON_B, and SLIDE_SWITCH that represent pins connected to components built-in to the board.

This guide was first published on Aug 28, 2017. It was last updated on Aug 28, 2017. This page (Board Pins) was last updated on Aug 20, 2019.