Eagle Tree Microsensor I2C Interface User Manual
Page 3

Copyright © 2009-2011 Eagle Tree Systems, LLC
http://www.eagletreesystems.com
i2c_restart(); // perform I2C restart
// select sensor in read mode
if (!i2c_write(| SENSOR_ADDRESS | I2C_READ_BIT)) {
// read two bytes of sensor data
data[0] = i2c_read(1);
data[1] = i2c_read(0);
reading = *((signed short *)(&data[0]));
}
}
}
i2c_stop();
Here is the pseudo code for accessing the G-Force sensors:
byte data[6];
signed short GX, GY, GZ;
i2c_start();
// select sensor in write mode
if (!(i2c_write(SENSOR_ADDRESS | I2C_WRITE_BIT))) {
// send "read data" command to sensor
if (!i2c_write(0x07)) {
i2c_restart(); // perform I2C restart
// select sensor in read mode
if (!i2c_write(| SENSOR_ADDRESS | I2C_READ_BIT)) {
// read 6 bytes of sensor data
data[0] = i2c_read(1);
data[1] = i2c_read(1);
data[2] = i2c_read(1);
data[3] = i2c_read(1);
data[4] = i2c_read(1);
data[5] = i2c_read(0);