by kgraf » Tue Dec 18, 2012 1:48 am
Trying to connect the L3GD20 gyro breakout board to mega2560 R3 microcontroller.
Uncertain about which pins to connect from gyro to mega
gnd on gyro board to any gnd on mega?
Vcc on gyro board to 3.3V or 5V on mega?
SCL on gyro to SCL 21 on mega? //communications section of mega
SDA on gyro to SDA 20 on mega? //communications section of mega
also, what is Wire.h and how include Adafruit_L3GD20.h with Adafruit_L3GD20.test in
sketchpad - sketch/add file?
#include <Wire.h>
#include <Adafruit_L3GD20.h>
when is the power connection needed on the mega board? I did the sample blink with
only the usb connected and it worked fine.
Re:
Getting started is easy - simply connect SDA to your Arduino I2C data pin (On the UNO this is A4), SCL to I2C clock (Uno: A5), GND to ground, and Vin to 3 or 5VDC. Then install and run our easy to use Arduino library, which will print out the XYZ sensor data to the serial terminal. Our library also supports SPI on any 4 digital I/O pins, see the example for wiring.
// By default, uses I2C
//Adafruit_L3GD20 gyro;
// Alternately, you can use SPI, but you have to define the pins
#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);