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.
| Board | Default SPI Pins | Additional SPI Pins | Notes |
|---|---|---|---|
| UNO R3, UNO R3 SMD, UNO WiFi Rev2, UNO Mini LE | 10(CS), 11(COPI), 12(CIPO), 13(SCK) | SPI pins available on ICSP header | |
| UNO R4 Minima, UNO R4 WiFi | 10(CS), 11(COPI), 12(CIPO), 13(SCK) | SPI pins available on ICSP header | |
| Leonardo, Yún Rev2, Zero | 10(CS), 11(COPI), 12(CIPO), 13(SCK) | SPI pins available on ICSP header | |
| Micro | 14(CIPO), 15(SCK), 16(COPI) | ||
| Nano boards | 11(COPI), 12(CIPO), 13(SCK) | ||
| MKR boards | 8(COPI), 9(SCK), 10(CIPO) | ||
| Due | 74(CIPO), 75(COPI), 76(SCK) | SPI pins available on dedicated SPI header | |
| GIGA R1 WiFi | 89(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 Rev3 | 50(CIPO), 51(COPI), 52(SCK), 53(CS) | SPI pins available on ICSP header |
Configuration
Transaction control
Data transfer
Deprecated
The following functions are deprecated. Use SPISettings with beginTransaction() instead.