understanding shiftIn and shiftOut

Hi all!!

I am trying to send data between 2 arduinos usingo shiftIn and Out. i defined master pins 22 and 24 as data an clock and initialized as OUTPUTS then i defined the same pins in the slave as data and clock and as INPUTS I am trying to send a byte from master to slave (value 125) so the slave receives it and just prints the value in serial, but i am just getting 255 as result. Any help? :)

The code for the master (sender) i am using is:


void setup() { pinMode(22,OUTPUT); //-- data pinMode(24,OUTPUT); //-- clock } void loop() { shiftOut(22,24,MSBFIRST, 125); delay(1000); }


and for the slave (receiver):


byte dataread = 0;

void setup() { pinMode(22,INPUT); //-- data pinMode(24,INPUT); //-- clock Serial.begin(9600); } void loop()

{ dataread = shiftIn(22,24,MSBFIRST); Serial.println(dataread); }


Not gonna work - slave is creating its own clock. Needs to sample the data based on the master's clock. Try SPI with master/slave here: http://www.gammon.com.au/forum/?id=10892