Created
March 14, 2017 21:58
-
-
Save GiovanniBalestrieri/738440f51de951cd644caa3ef953ed85 to your computer and use it in GitHub Desktop.
Accelerometer Basic ADXL345
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
//Analog read pins | |
const int xPin = 0; | |
const int yPin = 1; | |
const int zPin = 2; | |
int xRead,yRead,zRead; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Serial.println("Ready!"); | |
} | |
void loop() | |
{ | |
readAcc(); | |
printVals(); | |
delay(500); | |
} | |
// Read analog values from the Acc | |
void readAcc() | |
{ | |
xRead = analogRead(xPin); | |
yRead = analogRead(yPin); | |
zRead = analogRead(zPin); | |
} | |
void printVals() | |
{ | |
Serial.print(" X: "); | |
Serial.print(xRead); | |
Serial.print(" | Y: "); | |
Serial.print(yRead); | |
Serial.print(" | Z: "); | |
Serial.print(zRead); | |
Serial.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment