| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*****************************************************************************/
- // HighLevelExample.ino
- // Hardware: Grove - 6-Axis Accelerometer&Gyroscope
- // Arduino IDE: Arduino-1.65
- // Author: Lambor
- // Date: Oct,2015
- // Version: v1.0
- //
- // Modified by:
- // Data:
- // Description:
- //
- // by www.seeedstudio.com
- //
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Lesser General Public
- // License as published by the Free Software Foundation; either
- // version 2.1 of the License, or (at your option) any later version.
- //
- // This library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- // Lesser General Public License for more details.
- //
- // You should have received a copy of the GNU Lesser General Public
- // License along with this library; if not, write to the Free Software
- // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- //
- /*******************************************************************************/
- #include "LSM6DS3.h"
- #include "Wire.h"
- //Create a instance of class LSM6DS3
- LSM6DS3 myIMU(I2C_MODE, 0x6A); //I2C device address 0x6A
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- while (!Serial);
- //Call .begin() to configure the IMUs
- if (myIMU.begin() != 0) {
- Serial.println("Device error");
- } else {
- Serial.println("Device OK!");
- }
- }
- void loop() {
- //Accelerometer
- Serial.print("\nAccelerometer:\n");
- Serial.print(" X1 = ");
- Serial.println(myIMU.readFloatAccelX(), 4);
- Serial.print(" Y1 = ");
- Serial.println(myIMU.readFloatAccelY(), 4);
- Serial.print(" Z1 = ");
- Serial.println(myIMU.readFloatAccelZ(), 4);
- //Gyroscope
- Serial.print("\nGyroscope:\n");
- Serial.print(" X1 = ");
- Serial.println(myIMU.readFloatGyroX(), 4);
- Serial.print(" Y1 = ");
- Serial.println(myIMU.readFloatGyroY(), 4);
- Serial.print(" Z1 = ");
- Serial.println(myIMU.readFloatGyroZ(), 4);
- //Thermometer
- Serial.print("\nThermometer:\n");
- Serial.print(" Degrees C1 = ");
- Serial.println(myIMU.readTempC(), 4);
- Serial.print(" Degrees F1 = ");
- Serial.println(myIMU.readTempF(), 4);
- delay(1000);
- }
|