SPI between 2 Arduinos one as master and one as slave

The SD card has proper 3.3V buffering on it? So when its CS is high it's totally isolated? Same for the slave - when its CS is high, it's not interfering with the bus?

Silly mistake on my part! I hadn't initialized the correct CS pin of SD card to the Master Uno :sweat_smile:

So now they seem to work in tandem with each other.

But the problem remains that even though I'm getting the necessary commands from the Master Uno to print on the Hyper terminal of the Slave, my LEDs on the Slave are just not glowing :/ Further, I plan to replace the LEDs with up to 6 DC motors and therefore I need the SPI communication to happen perfectly and the GPIO pins to work (on the Slave).

Any suggestions on that? I'm really stuck in a rut here with this :(

Hello i want to recieve an array of data via SPI from a raspberry as master and the arduino as slave, but the method SPI.transfer(buffer,size) throw me an error, it said “55:6: note: candidate expects 1 argument, 2 provided”.

The next is the code which throw me the error, i try to modify the code of Nick but it doesn’t work, if i put the variable valor like a single byte not array it only recieve the last value of the array from the raspberry.

#include <SPI.h>
int buf;
byte valor[2];

void setup(){ 
  //Initiate an SPI communication instance.
  //SPI.begin();
  Serial.println ();
pinMode(MISO, OUTPUT);
  //Create a serial connection to display the data on the terminal.
  Serial.begin(115200); 
    // turn on SPI in slave mode
  SPCR |= _BV(SPE);
  // turn on interrupts
  SPCR |= _BV(SPIE);
}

ISR (SPI_STC_vect){
{
  SPI.transfer(valor,2);
 
  //buf=c;

  } // end of switch

}

void loop (void)
{

  Serial.println(valor[1]);
  
  delay (1000);
}  // end of loop

i already did it via UART there is the code, i hope somebody can help me to do the same but via SPI, thank you.

void setup(){
  Serial.begin(9600);
}
byte valor[3];
int x=0;
void loop() {

        
        if (Serial.available() > 0) {
               
                Serial.readBytes((char *)valor,sizeof (valor));
                x=(valor[0]+(valor[1] << 8));
                Serial.println(valor[0], DEC);
                Serial.println(valor[1], DEC);
        }
}

As stated in the SPI documentation page, the SPI library can only be used for the Arduino in Master mode. You can use the constants and such from the library but you have to do transmissions manually if you want to use it in Slave mode.

Does anybody know how to do this with ATSAMD21 based boards?

I am stumbling at setting up the slave, I think the following:

// turn on SPI in slave mode
SPCR |= _BV(SPE);

Apply only to ATMEGA based boards?

How to use Arduino maga to store run time data of arduino nano

I am using much of the slave code on the gammon.com SPI page, including the ISR (SPI_STC_vect). I'm using a Pro Mini for the slave and the external interrupt pins (2 and 3) are not connected to the master board. My SPI communication seems to be working fine.

Can you explain what is calling the ISR in the slave code? Is it the detection of incoming data on the MISO pin? Is this somehow handle in the SPI.h?

Here's a working example of exchanging data between two arduinos. See https://www.fpaynter.com/2020/03/arduino-spi-data-exchange-between-two-arduinos-in-a-master-slave-configuration/

Hope this helps,

Frank