Created
July 20, 2016 21:19
-
-
Save drews256/ef0ccecf478a9d073d0fdcfd9881606d 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
/* | |
ADXL335 | |
Reads an Analog Devices ADXL335 accelerometer and communicates the | |
acceleration to the computer. | |
Designed for the ADXL335 available at Tayda Electronics at | |
http://www.taydaelectronics.com/breakout-boards/adxl335-3-axis-accelerometer.html | |
http://www.arduino.cc/en/Tutorial/ADXL3xx | |
The circuit: | |
analog 6: x-axis | |
analog 5: y-axis | |
analog 4: z-axis | |
created 2 Jul 2008 | |
by David A. Mellis | |
modified 30 Aug 2011 | |
by Tom Igoe | |
modified 20 July 2016 | |
by Andrew Stuntz | |
This example code is in the public domain. | |
*/ | |
// these constants describe the pins. They won't change: | |
const int xpin = A6; // x-axis of the accelerometer | |
const int ypin = A5; // y-axis | |
const int zpin = A4; // z-axis (only on 3-axis models) | |
void setup() { | |
// initialize the serial communications: | |
Serial.begin(9600); | |
} | |
void loop() { | |
// print the sensor values: | |
Serial.print(analogRead(xpin)); | |
// print a tab between values: | |
Serial.print("\t"); | |
Serial.print(analogRead(ypin)); | |
// print a tab between values: | |
Serial.print("\t"); | |
Serial.print(analogRead(zpin)); | |
Serial.println(); | |
// delay before next reading: | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment