Complete the code to initialize SPI communication.
#include <SPI.h> void setup() { SPI.[1](); } void loop() { // Your code here }
start() or init() instead of begin().The SPI.begin() function initializes the SPI bus and must be called before using SPI communication.
Complete the code to send a byte of data over SPI.
byte data = 0x42; SPI.[1](data);
send() or write() which are not SPI library functions.The SPI.transfer() function sends a byte and simultaneously receives a byte over SPI.
Fix the error in setting the SPI clock divider to 16.
SPI.[1](SPI_CLOCK_DIV16);clockDivider() or setClock() which do not exist.The correct function to set the SPI clock speed divider is setClockDivider().
Fill both blanks to set SPI data mode and bit order.
SPI.[1](SPI_MODE0); SPI.[2](MSBFIRST);
setClockDivider() with data mode or bit order functions.setDataMode() sets the SPI mode (clock polarity and phase), and setBitOrder() sets the bit order (MSB or LSB first).
Fill all three blanks to start an SPI transaction with settings.
SPI.[1](SPISettings(4000000, [2], [3]));
endTransaction() instead of beginTransaction() to start.beginTransaction() starts an SPI transaction with specified settings: clock speed, bit order, and data mode.
