Last active
February 18, 2019 06:16
-
-
Save li2hub/d6dbc866fc82975a6d2707e93451c942 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_ADXL345_U.h> | |
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); | |
void setup() | |
{ | |
Serial.begin(115200); | |
if(!accel.begin()) | |
{ | |
Serial.println("Ooops, no ADXL345 detected ... Check your wiring!"); | |
while(1); | |
} | |
accel.setRange(ADXL345_RANGE_4_G); | |
} | |
void loop() | |
{ | |
sensors_event_t event; | |
accel.getEvent(&event); | |
Serial.print((event.acceleration.x)/9.8); Serial.print(","); | |
Serial.print((event.acceleration.y)/9.8); Serial.print(","); | |
Serial.println((event.acceleration.z)/9.8); | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment