Hello everyone,
I am trying to test if SPI is working. I want to send an array containing 4 integer elements from Pi to Arduino UNO and print the array on the Arduino side to make sure I get the values from the register. However, at the moment im not getting any output. I have attached my code below:
Raspberry Pi (master) code:
import spidev
import time
spi=spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz = 125000
to_send = [10, 20, 30, 40]
spi.xfer(to_send)
spi.close()
Arduino Slave Code
#include <SPI.h>
void setup() {
Serial.begin (125000); // debugging
// turn on SPI in slave mode
SPCR |= bit (SPE);
// have to send on master in, slave out
pinMode(MISO, OUTPUT);
// now turn on interrupts
SPI.attachInterrupt();
}
// SPI interrupt routine
ISR (SPI_STC_vect) {
int c = SPDR;
Serial.println(c); }
void loop() {}