Code Monkey home page Code Monkey logo

l3g-arduino's Introduction

Arduino library for Pololu L3G boards

Version: 1.2.2
Release Date: 2014-02-05
www.pololu.com

Summary

This is a library for the Arduino that interfaces with L3GD20H, L3GD20, and L3G4200D gyros on Pololu boards. It makes it simple to read the raw gyro data from these boards:

Getting Started

Software

Download the archive from GitHub, decompress it, and move the “L3G” folder into the “libraries” subdirectory inside your Arduino sketchbook directory. You can view your sketchbook location by selecting File→Preferences in the Arduino environment; if there is not already a “libraries” folder in that location, you should create it yourself. After installing the library, restart the Arduino environment so it can find the L3G library and its example.

Hardware

Make the following connections with wires between the Arduino and the L3G board:

Arduino Uno R3, Leonardo, Mega 2560

Arduino      L3G board
----------------------
     5V  ->  VIN
    GND  ->  GND
    SDA  ->  SDA
    SCL  ->  SCL

Arduino Micro

Arduino      L3G board
----------------------
     5V  ->  VIN
    GND  ->  GND
      2  ->  SDA
      3  ->  SCL

Arduino Uno (up to R2), Duemilanove, etc.

Arduino      L3G board
----------------------
     5V  ->  VIN
    GND  ->  GND
     A4  ->  SDA
     A5  ->  SCL

Example Programs

Open an example code sketch by selecting File→Examples→L3G→example_name

Serial

This program continuously reads the gyro, communicating the readings over the serial interface. You can display the readings with the Arduino Serial Monitor.

Example output:

G X: 188 Y: -10 Z: -47
G X: 138 Y: -40 Z: -26
G X: 110 Y: -55 Z: 4

Other Library Applications

These programs make use of the L3G library but are not included with in the library archive or repository.

MinIMU-9 + Arduino AHRS
This sketch allows an Arduino connected to a MinIMU-9 or AltIMU-10 to function as an attitude and heading reference system, calculating estimated roll, pitch, and yaw angles from sensor readings that can be visualized with a 3D test program on a PC. It is based on the work of Jordi Munoz, William Premerlani, Jose Julio, and Doug Weibel.
Pololu_Open_IMU by mikeshub
This is an alternative AHRS implementation that uses the Madgwick algorithm.
ascii_graph by drewtm
This sketch outputs a text-based graph of LSM303 accelerometer and L3G gyro data, providing a quick way to check whether the sensors are working as expected.

Library Reference

vector g
The last values read from the gyro.
bool init(byte device, byte sa0)
Initializes the library with the device being used (L3G4200D or L3GD20) and the state of the SA0 (slave address least significant bit) pin. Constants for these arguments are defined in L3G.h. Both of these arguments are optional; if they are not specified, the library will try to automatically detect the device and slave address, and it will return a boolean indicating whether the autodetection was succesful.
Note: Automatic detection of the device type currently does not work with the Arduino Due because of issues with its Wire library. To work around this, specify the device and SA0 state manually (e.g. init(L3GD20_DEVICE, L3G_SA0_HIGH)).
void enableDefault(void)
Turns on the gyro in the default configuration.
void writeReg(byte reg, byte value)
Writes a gyro register with the given value. Register address constants are defined in L3G.h.
byte readReg(byte reg)
Reads a gyro register and returns the value read.
void read(void)
Takes a reading from the gyro and stores the values in the vector g.

Differences from the L3G4200D library

This library is very similar to our earlier L3G4200D library, which is not compatible with the L3GD20. Besides the name change, the main difference in this library is that you need to call the init() function before using any of the other library functions, typically from within the Arduino setup() function. While the older library only works with the Pololu boards’ default gyro slave address of 1101001b, this library allows you to specify the slave address with the init() function.

Version History

  • 1.2.2 (2014-02-05): Added support for L3GD20H.
  • 1.2.1 (2012-10-31): Cast sensor readings to 16-bit ints for better portability.
  • 1.2.0 (2012-07-06): Renamed library to L3G and added support for L3GD20.
  • 1.1.0 (2011-12-12): Arduino 1.0 compatibility.
  • 1.0.0 (2011-09-14): Original release of L3G4200D library.

l3g-arduino's People

Contributors

kevin-pololu avatar jtf006 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.