HighLevelExample.ino 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*****************************************************************************/
  2. // HighLevelExample.ino
  3. // Hardware: Grove - 6-Axis Accelerometer&Gyroscope
  4. // Arduino IDE: Arduino-1.65
  5. // Author: Lambor
  6. // Date: Oct,2015
  7. // Version: v1.0
  8. //
  9. // Modified by:
  10. // Data:
  11. // Description:
  12. //
  13. // by www.seeedstudio.com
  14. //
  15. // This library is free software; you can redistribute it and/or
  16. // modify it under the terms of the GNU Lesser General Public
  17. // License as published by the Free Software Foundation; either
  18. // version 2.1 of the License, or (at your option) any later version.
  19. //
  20. // This library is distributed in the hope that it will be useful,
  21. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  23. // Lesser General Public License for more details.
  24. //
  25. // You should have received a copy of the GNU Lesser General Public
  26. // License along with this library; if not, write to the Free Software
  27. // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. //
  29. /*******************************************************************************/
  30. #include "SparkFunLSM6DS3.h"
  31. #include "Wire.h"
  32. //Create a instance of class LSM6DS3
  33. LSM6DS3 myIMU(I2C_MODE, 0x6A); //I2C device address 0x6A
  34. void setup() {
  35. // put your setup code here, to run once:
  36. Serial.begin(9600);
  37. //Call .begin() to configure the IMUs
  38. if (myIMU.begin() != 0) {
  39. Serial.println("Device error");
  40. } else {
  41. Serial.println("Device OK!");
  42. }
  43. }
  44. void loop() {
  45. //Accelerometer
  46. Serial.print("\nAccelerometer:\n");
  47. Serial.print(" X1 = ");
  48. Serial.println(myIMU.readFloatAccelX(), 4);
  49. Serial.print(" Y1 = ");
  50. Serial.println(myIMU.readFloatAccelY(), 4);
  51. Serial.print(" Z1 = ");
  52. Serial.println(myIMU.readFloatAccelZ(), 4);
  53. //Gyroscope
  54. Serial.print("\nGyroscope:\n");
  55. Serial.print(" X1 = ");
  56. Serial.println(myIMU.readFloatGyroX(), 4);
  57. Serial.print(" Y1 = ");
  58. Serial.println(myIMU.readFloatGyroY(), 4);
  59. Serial.print(" Z1 = ");
  60. Serial.println(myIMU.readFloatGyroZ(), 4);
  61. //Thermometer
  62. Serial.print("\nThermometer:\n");
  63. Serial.print(" Degrees C1 = ");
  64. Serial.println(myIMU.readTempC(), 4);
  65. Serial.print(" Degrees F1 = ");
  66. Serial.println(myIMU.readTempF(), 4);
  67. delay(1000);
  68. }