Hello i want to receive 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 as 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[2];
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);
}
}