Description

The SPI library allows you to communicate with SPI devices, with the Arduino board as the controller device. This library is bundled with every Arduino platform (avr, megaavr, mbed, samd, sam, arc32), so you do not need to install it separately.

To use this library, include it at the top of your sketch:

#include <SPI.h>

To learn more about Arduino and SPI, visit the Arduino & Serial Peripheral Interface (SPI) guide.

Default SPI Pins

BoardDefault SPI PinsAdditional SPI PinsNotes
UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini LE10(CS), 11(COPI), 12(CIPO), 13(SCK)SPI pins available on ICSP header
UNO R4 Minima, UNO R4 WiFi10(CS), 11(COPI), 12(CIPO), 13(SCK)SPI pins available on ICSP header
Leonardo, Yún Rev2, Zero10(CS), 11(COPI), 12(CIPO), 13(SCK)SPI pins available on ICSP header
Micro14(CIPO), 15(SCK), 16(COPI)
Nano boards11(COPI), 12(CIPO), 13(SCK)
MKR boards8(COPI), 9(SCK), 10(CIPO)
Due74(CIPO), 75(COPI), 76(SCK)SPI pins available on dedicated SPI header
GIGA R1 WiFi89(CIPO), 90(COPI), 91(SCK)12(CIPO), 11(COPI), 13(SCK), 10(CS)Pins 89, 90, 91 are located on the SPI header
Mega 2560 Rev350(CIPO), 51(COPI), 52(SCK), 53(CS)SPI pins available on ICSP header

Functions

Configuration

Transaction control

Data transfer

Deprecated

The following functions are deprecated. Use SPISettings with beginTransaction() instead.