#include <SPI.h>
#define CSPIN 1
void setup() {
pinMode(CSPIN, OUTPUT); // init chip select pin as an output
digitalWrite(CSPIN, 1); // most slaves interpret a high level on CS as "deasserted"
SPI.begin();
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
digitalWrite(CSPIN, 0);
unsigned char sent = 0x01;
unsigned char received = SPI.transfer(sent);
// more data could be transferred here
digitalWrite(CSPIN, 1);
SPI.endTransaction();
SPI.end();
}
void loop() {
// we don't need loop code in this example.
}
This example: