user14090: A master will send fan speed values to the slave. The slave will then read the fan speed values and change the speed value for the relevant pwm pin. However I am not sure how I can tell the slave which pin the data is for.  Should I send two packets of data in quick sucsession and then have a loop system wherby the first peice of data out of two is always for specifying the pin? Any help in tackling this would be greatly appreciated. 

user10794: You can use a struct to send multiple things, like this:
#include <Wire.h>

const byte SLAVE_ADDRESS = 42;

struct t_message
{
  byte pin;
  byte speed;
} message;

void setup ()
{
  Wire.begin ();   // initialize master
}  // end of setup

void loop ()
{
  // set desired parameters
  message.pin = 10;
  message.speed = 50;

  // send the message
  Wire.beginTransmission (SLAVE_ADDRESS);  
  Wire.write ((byte *) &message, sizeof message);
  Wire.endTransmission ();
}  // end of loop


More information about I2C - Two-Wire Peripheral Interface - for Arduino

On that page is mentioned how to Send and receive any data type. This includes structs. Using the code there you could send a struct, and receive a struct.

14090: <p>A master will send fan speed values to the slave. The slave will then read the fan speed values and change the speed value for the relevant pwm pin. However I am not sure how I can tell the slave which pin the data is for.  Should I send two packets of data in quick sucsession and then have a loop system wherby the first peice of data out of two is always for specifying the pin? Any help in tackling this would be greatly appreciated. </p>
 10794: <p>You can use a struct to send multiple things, like this:</p>



<pre class="lang-C++ prettyprint-override"><code>#include &lt;Wire.h&gt;

const byte SLAVE_ADDRESS = 42;

struct t_message
{
  byte pin;
  byte speed;
} message;

void setup ()
{
  Wire.begin ();   // initialize master
}  // end of setup

void loop ()
{
  // set desired parameters
  message.pin = 10;
  message.speed = 50;

  // send the message
  Wire.beginTransmission (SLAVE_ADDRESS);  
  Wire.write ((byte *) &amp;message, sizeof message);
  Wire.endTransmission ();
}  // end of loop
</code></pre>

<hr>

<p>More information about <a href="http://www.gammon.com.au/i2c" rel="nofollow">I2C - Two-Wire Peripheral Interface - for Arduino</a></p>

<hr>

<p>On that page is mentioned how to <a href="http://www.gammon.com.au/forum/?id=10896&amp;reply=8#reply8" rel="nofollow">Send and receive any data type</a>. This includes structs. Using the code there you could send a struct, and receive a struct.</p>
