HighLevelExample.ino 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*****************************************************************************/
  2. // BasicExample.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. #include "SPI.h"
  33. //Create a instance of class LSM6DS3
  34. LSM6DS3 myIMU( I2C_MODE, 0x6A ); //I2C device address 0x6A
  35. void setup() {
  36. // put your setup code here, to run once:
  37. Serial.begin(9600);
  38. //Call .begin() to configure the IMUs
  39. if( myIMU.begin() != 0 )
  40. {
  41. Serial.println("Device error");
  42. }
  43. else
  44. {
  45. Serial.println("Device OK!");
  46. }
  47. }
  48. void loop()
  49. {
  50. //Accelerometer
  51. Serial.print("\nAccelerometer:\n");
  52. Serial.print(" X1 = ");
  53. Serial.println(myIMU.readFloatAccelX(), 4);
  54. Serial.print(" Y1 = ");
  55. Serial.println(myIMU.readFloatAccelY(), 4);
  56. Serial.print(" Z1 = ");
  57. Serial.println(myIMU.readFloatAccelZ(), 4);
  58. //Gyroscope
  59. Serial.print("\nGyroscope:\n");
  60. Serial.print(" X1 = ");
  61. Serial.println(myIMU.readFloatGyroX(), 4);
  62. Serial.print(" Y1 = ");
  63. Serial.println(myIMU.readFloatGyroY(), 4);
  64. Serial.print(" Z1 = ");
  65. Serial.println(myIMU.readFloatGyroZ(), 4);
  66. //Thermometer
  67. Serial.print("\nThermometer:\n");
  68. Serial.print(" Degrees C1 = ");
  69. Serial.println(myIMU.readTempC(), 4);
  70. Serial.print(" Degrees F1 = ");
  71. Serial.println(myIMU.readTempF(), 4);
  72. delay(1000);
  73. }