Regarding packing and unpacking bits, see the Firmata I2C feature. See [byte 3 of the I2C read/write request](https://github.com/firmata/protocol/blob/master/i2c.md). And see the it in use [here](https://github.com/firmata/arduino/blob/configurable/utility/I2CFirmata.cpp#L120). There are a couple of different approaches. In this one the constants map to the values of the unmasked bits. The other way people do this is mask and then shift right to the set of bits you're evaluating.