On the page you linked
To write to a register, send the chip the register address followed by the desired data.
The full code is :
#define REGISTER_CONFIG (6)
void gpio_dir(int address, int dir) {
// Send config register address
Wire.beginTransmission(address);
Wire.send(REGISTER_CONFIG);
// Connect to device and send two bytes
Wire.send(0xff & dir); // low byte
Wire.send(dir >> 8); // high byte
Wire.endTransmission();
}
You're using a PCA9555, 16bit I/O expander, so by looking at the datasheet pf the chip, you see that
The Configuration registers (registers 6 and 7) configure the directions of the I/O pins. If a bit in this register is
set to 1, the corresponding port pin is enabled as an input with a high-impedance output driver. If a bit in this
register is cleared to 0, the corresponding port pin is enabled as an output.
Register 6 is the configuration for 8 I/O pins, register 7 for the 8 olthers pins.
So, you are sending the number 6 to the chip to tell it that you want to access the register number 6 (REGISTER_CONFIG = 6).
In the code from the page, the variable dir is an integer used to tell which pins will be an input & which ones will be outputs.
Have a look here for the bitwise operators : http://www.arduino.cc/en/Tutorial/BitMask