Hardware Reference
In-Depth Information
Figure 13-5. Arduino SPI master-slave wiring
We will use the Arduino SPI master test sketch and an Arduino SPI slave sketch, which will process the
commands, expected returns, and values from the master, and confirm that an action occurred properly. Listing 13-8
shows the configuration of the slave SPI Arduino.
Listing 13-8. SPI_Slave_test.ino
/*
* SPI Slave test program
* by Rick Anderson
*
* Set the defaults:
* MSBFIRST
* DataMode = SPI_MODE0;
* Clock divider = SPI_CLOCK_DIV4,
*/
#include <SPI.h>
const byte TESTBYTE = 0b11110000;
void setup()
{
Serial.begin(9600);
 
Search WWH ::




Custom Search