#include <SPI.h>
static boolean received = false;
static byte message;
ISR (SPI_STC_vect)
{
message = SPDR;
received = true;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(MISO,OUTPUT);
SPCR |= (1<<SPE);
SPI.attachInterrupt();
}
void loop() {
// put your main code here, to run repeatedly:
if (received) {
Serial.print("message received: 0x");
Serial.println(message, HEX);
}
}