HighLevelExample.ino 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. {
  40. Serial.println("Device error");
  41. }
  42. else
  43. {
  44. Serial.println("Device OK!");
  45. }
  46. }
  47. void loop()
  48. {
  49. //Accelerometer
  50. Serial.print("\nAccelerometer:\n");
  51. Serial.print(" X1 = ");
  52. Serial.println(myIMU.readFloatAccelX(), 4);
  53. Serial.print(" Y1 = ");
  54. Serial.println(myIMU.readFloatAccelY(), 4);
  55. Serial.print(" Z1 = ");
  56. Serial.println(myIMU.readFloatAccelZ(), 4);
  57. //Gyroscope
  58. Serial.print("\nGyroscope:\n");
  59. Serial.print(" X1 = ");
  60. Serial.println(myIMU.readFloatGyroX(), 4);
  61. Serial.print(" Y1 = ");
  62. Serial.println(myIMU.readFloatGyroY(), 4);
  63. Serial.print(" Z1 = ");
  64. Serial.println(myIMU.readFloatGyroZ(), 4);
  65. //Thermometer
  66. Serial.print("\nThermometer:\n");
  67. Serial.print(" Degrees C1 = ");
  68. Serial.println(myIMU.readTempC(), 4);
  69. Serial.print(" Degrees F1 = ");
  70. Serial.println(myIMU.readTempF(), 4);
  71. delay(1000);
  72. }