Datasheet

SPI Example: (use with SPI wiring (https://adafru.it/aV6))
Initialization:
Before using the device object you constructed, you must initialize it with the sensitivity range you want to use:
bool begin(gyroRange_t rng);
where "rng" can be one of:
L3DS20_RANGE_250DPS - for 250 degrees-per-second range (default)
L3DS20_RANGE_500DPS - for 500 degrees-per-second range
L3DS20_RANGE_2000DPS - for 2000 degrees-per-second range
Example:
Sensing Rotation:
To sense rotation, you must first call the "read()" function to take a reading:
void read(void);
This function takes no parameters. After calling "read()". The raw x, y and z readings can be retrieved from the device
object's "data" member.
data.x - x-axis rotation rate in degrees-per-second
data.y - y-axis rotation rate in degrees-per-second
data.z - z-axis rotation rate in degrees-per-second
Example:
// Define the pins for SPI
#define GYRO_CS 4 // labeled CS
#define GYRO_DO 5 // labeled SA0
#define GYRO_DI 6 // labeled SDA
#define GYRO_CLK 7 // labeled SCL
Adafruit_L3GD20 gyro(GYRO_CS, GYRO_DO, GYRO_DI, GYRO_CLK);
void setup()
{
Serial.begin(9600);
// Try to initialise and warn if we couldn't detect the chip
if (!gyro.begin(gyro.L3DS20_RANGE_250DPS))
{
Serial.println("Oops ... unable to initialize the L3GD20. Check your wiring!");
while (1);
}
}
© Adafruit Industries https://learn.adafruit.com/adafruit-triple-axis-gyro-breakout Page 9 of 18