understanding shiftIn and shiftOut
hi all!!
i trying send data between 2 arduinos usingo shiftin , out.
i defined master pins 22 , 24 data clock , initialized outputs
then defined same pins in slave data , clock , inputs
i trying send byte master slave (value 125) slave receives it
and prints value in serial, getting 255 result.
any help?
the code master (sender) using is:
-----------------------------------------
void setup()
{
pinmode(22,output); //-- data
pinmode(24,output); //-- clock
}
void loop() { shiftout(22,24,msbfirst, 125); delay(1000); }
--------------------------------------------------------
and 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); }
------------------------------------------------------------------
i trying send data between 2 arduinos usingo shiftin , out.
i defined master pins 22 , 24 data clock , initialized outputs
then defined same pins in slave data , clock , inputs
i trying send byte master slave (value 125) slave receives it
and prints value in serial, getting 255 result.
any help?

the code master (sender) using is:
-----------------------------------------
void setup()
{
pinmode(22,output); //-- data
pinmode(24,output); //-- clock
}
void loop() { shiftout(22,24,msbfirst, 125); delay(1000); }
--------------------------------------------------------
and 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 creating own clock. needs sample data based on master's clock.
try spi master/slave here:
http://www.gammon.com.au/forum/?id=10892
try spi master/slave here:
http://www.gammon.com.au/forum/?id=10892
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > understanding shiftIn and shiftOut
arduino
Comments
Post a Comment