Permalink
Browse files

added Serial example, license, and readme

  • Loading branch information...
1 parent c6ec86d commit b1962ec95099760b8a218645feadf8e5204d6914 @kevin-pololu kevin-pololu committed Sep 6, 2011
Showing with 112 additions and 0 deletions.
  1. +24 −0 L3G4200D/examples/Serial/Serial.pde
  2. +25 −0 LICENSE.txt
  3. +63 −0 README.textile
@@ -0,0 +1,24 @@
+#include <Wire.h>
+#include <L3G4200D.h>
+
+L3G4200D gyro;
+
+void setup() {
+ Serial.begin(9600);
+ Wire.begin();
+ gyro.enableDefault();
+}
+
+void loop() {
+ gyro.read();
+
+ Serial.print("G ");
+ Serial.print("X: ");
+ Serial.print(gyro.g.x);
+ Serial.print(" Y: ");
+ Serial.print(gyro.g.y);
+ Serial.print(" Z: ");
+ Serial.println(gyro.g.z);
+
+ delay(100);
+}
View
@@ -0,0 +1,25 @@
+Copyright (c) 2011 Pololu Corporation. For more information, see
+
+http://www.pololu.com/
+http://forum.pololu.com/
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,63 @@
+h1. Arduino library for the Pololu LSM303DLH carrier board
+
+Version: 1.0.0
+Release Date: 2011-01-20
+http://www.pololu.com/
+
+h2. Summary
+
+This is a library for the "Arduino":http://pololu.com/catalog/product/1616 that interfaces with the Pololu "LSM303DLH 3D compass and accelerometer carrier":http://www.pololu.com/catalog/product/1250. It makes it simple to read the raw accelerometer and magnetometer data, and it has a function for computing the tilt-compensated heading for those looking to use this sensor as a tilt-compensated compass.
+
+h2. Getting Started
+
+h3. Software
+
+Download the archive from "GitHub":https://github.com/ryantm/LSM303DLH, decompress it, and drag the "LSM303DLH" folder to your arduino-00xx/libraries directory. Then restart the Arduino environment, so the libraries can be updated to include the LSM303DLH library and its examples.
+
+h3. Hardware
+
+The board for the LSM303DLH can be purchased on "Pololu's website":http://www.pololu.com/catalog/product/1250.
+
+After receiving the board, make the following connections with wires:
+
+pre. Arduino Uno/Duemilanove LSM303DLH Carrier
+ 5V -> VIN
+ GND -> GND
+ Analog Pin 5 -> SCL
+ Analog Pin 4 -> SDA
+
+pre. Arduino Mega LSM303DLH Carrier
+ 5V -> VIN
+ GND -> GND
+ Analog Pin 21 -> SCL
+ Analog Pin 20 -> SDA
+
+h2. Example Programs
+
+Open the example code sketch by going to File->Examples->LSM303DLH->example_name
+
+h3. Serial
+
+Program the Arduino, and the accelerometer and magnetometer readings will be output to the serial monitor. Here is an example of what you will see:
+
+pre. A X: -151 Y: 848 Z: -509 M X: 281 Y: -442 Z: 87
+A X: -147 Y: 847 Z: -509 M X: 266 Y: -446 Z: 78
+A X: -147 Y: 849 Z: -508 M X: 280 Y: -450 Z: 81
+
+For calibration purposes it is useful to record the maximum and minimum magnetometer values you get when moving the compass through every possible orientation.
+
+h3. Heading
+
+Program the Arduino, and the tilt-compensated degrees of the heading from the -Y axis will be output to the serial monitor.
+
+h2. Command Reference
+
+pre. vector a - the last reading of the accelerometer values.
+vector m - the last reading of the magnetometer values.
+vector m_max - the maximum magnetometer readings found, use for calibration.
+vector m_min - the minimum magnetometer readings found, use for calibration.
+LSM303DLH() - Constructor
+void enable(void) - Turns on the magnetometer and accelerometer
+void read(void) - Takes a reading and stores the values in the vectors a and m.
+int heading(void) - Returns the tilt-compensated degrees headed away from the -Y axis
+int heading(vector from) - Returns the tilt-compensated degrees headed away from from

0 comments on commit b1962ec

Please sign in to comment.