SPI Communication between arduino adk and arduino mega

Hello everyone ,
i am doing the SPI communication between arduino ADK and arduino Mega . when i am doing this with normal code or you can with normal loop it's working but when i am connecting XBOX to Arduino ADK and try to get some value in arduino mega it's not working . inshort i want do communication between mega and adk and some button of xbox is pressed i want send some valu to mega . please give me the guidance.

Master code

''' include<SPI.h>

int x;
void setup (void)

{
Serial.begin(115200);

SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV8);
digitalWrite(SS,HIGH);
}

void loop(void)
{
byte m_send,m_receive;

x = 1;

digitalWrite(SS, LOW);

m_send = x;
m_receive=SPI.transfer(m_send);

Serial.println(m_receive);
delay(1000);
}

'''

Slave code

'''include<SPI.h>

volatile boolean received;
volatile byte Slavereceived,Slavesend;

int x;

void setup()

{
Serial.begin(115200);

pinMode(MISO,OUTPUT);

SPCR |= _BV(SPE);
received = false;

SPI.attachInterrupt();

}

ISR (SPI_STC_vect)
{
Slavereceived = SPDR;
received = true;
}

void loop()
{
if(received)
{
Serial.println(Slavereceived);

x=9;

Slavesend=x;
SPDR = Slavesend;
delay(1000);
}
}
'''

this was my normal code which is working.

Are there any wires between the 2 devices?... Schematics please!

Thanks for trying to use code tags. Can you replace your ticks (''') by backticks (```) please so he code is properly displayed.

Not familiar with the ADK so can't help.

What are these Greeks -- XBOX and ADK?

ADK is the Mega ADK (see topic title); no idea further about it.
XBOX is, I guess, an expensive toy to play video games.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.