Advertisement
microrobotics

SmartEverything LSM6DS3 Arduino Libraries

Jun 15th, 2017
4,896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. // Based on the SmartEverything LSM6DS3 Arduino Libraries
  2. // http://www.arduinolibraries.info/libraries/smart-everything-lsm6-ds3
  3. // Library code for LSM6DS3 iNEMO inertial module:3D accelerometer, 3D gyroscope
  4.  
  5. #include <Arduino.h>
  6. #include "LSM6DS3.h"
  7. #include "Wire.h"
  8.  
  9. void setup() {
  10.     Wire.begin();
  11.     Serial.begin(115200);  
  12.     while(!Serial){};
  13.     gyroscope.begin();
  14.     if(gyroscope.isActive()){
  15.         Serial.println("Gyroscope Already Active");
  16.     }else{
  17.         if(gyroscope.powerOn()){
  18.             Serial.println("Gyroscope Power ON");
  19.         }else{
  20.             Serial.println("Gyroscope Not Powered On");
  21.         }
  22.     }
  23. }
  24.  
  25. void loop() {
  26.     Serial.println("++++++++++++++++++++++++++++++++++++++++");
  27.     Serial.println("Gyroscope Values ");
  28.     Serial.print("Raw  X = ");
  29.     Serial.print(gyroscope.getRawXAxis());
  30.     Serial.print("  Y = ");
  31.     Serial.print(gyroscope.getRawYAxis());
  32.     Serial.print("  Z = ");
  33.     Serial.println(gyroscope.getRawZAxis());
  34.     Serial.print("X = ");
  35.     Serial.print(gyroscope.getConvertedXAxis(), 2);
  36.     Serial.print("dms  Y = ");
  37.     Serial.print(gyroscope.getConvertedYAxis(), 2);
  38.     Serial.print("dms  Z = ");
  39.     Serial.print(gyroscope.getConvertedZAxis(), 2);
  40.     Serial.println("dms");
  41.     Serial.println("++++++++++++++++++++++++++++++++++++++++");
  42.     delay(1000);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement