Arduino Forum

Using Arduino => Programming Questions => Topic started by: Suyash_Suvare on Apr 23, 2019, 12:27 pm

Title: about receiving 2 integer numbers at a time
Post by: Suyash_Suvare on Apr 23, 2019, 12:27 pm
i want to send two integer values at a time from master to slave while using I2C communication.
i am sending 'revo' & 'count' from master to slave.
i have used:

  Wire.beginTransmission(0x40);
  Wire.write(count);
  Wire.endTransmission();
  delay(500);

  Wire.beginTransmission(0x40);
  Wire.write(revo);
  Wire.endTransmission();
  delay(500);

 this code:

but i m receiving both numbers assign to single variable.
i actual i need revo as a variable and count as a another variable.
so what can  do for that??
please help.
Title: Re: about receiving 2 integer numbers at a time
Post by: UKHeliBob on Apr 23, 2019, 12:44 pm
You could receive the first one, copy it to another variable then receive the second one, but how will you know which is which ?

You would be better sending an array of two ints

Code: [Select]
Wire.write(theArray, numberOfBytesToSend)