Data Sheet

Core Spartan Documentation Modern Robotics, Inc
Version 3.0.3 Page 39
9.1. I2C Class
The I2C class was design to make generic I2C reads and writes easier to use. I2C class
makes use of the Wire library provided by Arduino.
I2C Functions:
CORE_I2C(int address)
void request(int location, int length)
unsigned char read(void)
int available(void)
void write(int location, unsigned char data)
void write(int location, unsigned char data[], int length)
CORE_I2C(int address)
Save the I2C address for future reads and writes. This must be done before
setup().
CORE_I2C sensor;
…or…
CORE_I2C sensor(0x12);
void request(int location, int length)
Request any number of bytes (up to 16 bytes) to be read from an I2C sensor. The
parameter location is the starting register location and length is the number of
bytes to return. When request is called the values are read and stored into a
buffer that can be accessed using the read() function.
sensor.request(0x04, 2);
…or…
sensor.request(0x00, 4);
unsigned char read(void)
Returns the next available byte in the I2C read buffer that was created from the
request() function. This function must be called each time
value = sensor.read();
…or…
Serial.println(sensor.read());