Last active
November 3, 2023 03:58
-
-
Save penpencool/d55dfc187e3522350b7edac17373a3ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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_ADXL345_U.h> | |
| Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(); | |
| void setup() { | |
| Serial.begin(9600); | |
| if(!accel.begin()) { | |
| Serial.println("Could not find a valid ADXL345 sensor, check wiring!"); | |
| while(1); | |
| } | |
| } | |
| void loop() { | |
| sensors_event_t event; | |
| accel.getEvent(&event); | |
| Serial.print("Acceleration (m/s^2): X="); Serial.print(event.acceleration.x); | |
| Serial.print(" Y="); Serial.print(event.acceleration.y); | |
| Serial.print(" Z="); Serial.println(event.acceleration.z); | |
| delay(500); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment