Devices & Components
Arduino Uno Rev3
Hourglass
SparkFun Triple Axis Accelerometer Breakout - ADXL335
Jumper wires (generic)
Solderless Breadboard Half Size
USB-A to B Cable
Hardware & Tools
velcro
Software & Tools
MAX
Project description
Code
https://www.arduino.cc/en/Tutorial/ADXL3xx
arduino
This is the basic ADXL3xx code from Ardunio examples - https://www.arduino.cc/en/Tutorial/ADXL3xx
1/* 2 ADXL3xx 3 4 Reads an Analog Devices ADXL3xx accelerometer and communicates the 5 acceleration to the computer. The pins used are designed to be easily 6 compatible with the breakout boards from SparkFun, available from: 7 http://www.sparkfun.com/commerce/categories.php?c=80 8 9 The circuit: 10 - analog 0: accelerometer self test 11 - analog 1: z-axis 12 - analog 2: y-axis 13 - analog 3: x-axis 14 - analog 4: ground 15 - analog 5: vcc 16 17 created 2 Jul 2008 18 by David A. Mellis 19 modified 30 Aug 2011 20 by Tom Igoe 21 22 This example code is in the public domain. 23 24 http://www.arduino.cc/en/Tutorial/ADXL3xx 25*/ 26 27// these constants describe the pins. They won't change: 28const int groundpin = 18; // analog input pin 4 -- ground 29const int powerpin = 19; // analog input pin 5 -- voltage 30const int xpin = A3; // x-axis of the accelerometer 31const int ypin = A2; // y-axis 32const int zpin = A1; // z-axis (only on 3-axis models) 33 34void setup() { 35 // initialize the serial communications: 36 Serial.begin(9600); 37 38 // Provide ground and power by using the analog inputs as normal digital pins. 39 // This makes it possible to directly connect the breakout board to the 40 // Arduino. If you use the normal 5V and GND pins on the Arduino, 41 // you can remove these lines. 42 pinMode(groundpin, OUTPUT); 43 pinMode(powerpin, OUTPUT); 44 digitalWrite(groundpin, LOW); 45 digitalWrite(powerpin, HIGH); 46} 47 48void loop() { 49 // print the sensor values: 50 Serial.print(analogRead(xpin)); 51 // print a tab between values: 52 Serial.print("\ "); 53 Serial.print(analogRead(ypin)); 54 // print a tab between values: 55 Serial.print("\ "); 56 Serial.print(analogRead(zpin)); 57 Serial.println(); 58 // delay before next reading: 59 delay(100); 60} 61[Get Code] 62
https://www.arduino.cc/en/Tutorial/ADXL3xx
arduino
This is the basic ADXL3xx code from Ardunio examples - https://www.arduino.cc/en/Tutorial/ADXL3xx
1/* 2 ADXL3xx 3 4 Reads an Analog Devices ADXL3xx accelerometer and communicates the 5 acceleration to the computer. The pins used are designed to be easily 6 compatible with the breakout boards from SparkFun, available from: 7 http://www.sparkfun.com/commerce/categories.php?c=80 8 9 The circuit: 10 - analog 0: accelerometer self test 11 - analog 1: z-axis 12 - analog 2: y-axis 13 - analog 3: x-axis 14 - analog 4: ground 15 - analog 5: vcc 16 17 created 2 Jul 2008 18 by David A. Mellis 19 modified 30 Aug 2011 20 by Tom Igoe 21 22 This example code is in the public domain. 23 24 http://www.arduino.cc/en/Tutorial/ADXL3xx 25*/ 26 27// these constants describe the pins. They won't change: 28const int groundpin = 18; // analog input pin 4 -- ground 29const int powerpin = 19; // analog input pin 5 -- voltage 30const int xpin = A3; // x-axis of the accelerometer 31const int ypin = A2; // y-axis 32const int zpin = A1; // z-axis (only on 3-axis models) 33 34void setup() { 35 // initialize the serial communications: 36 Serial.begin(9600); 37 38 // Provide ground and power by using the analog inputs as normal digital pins. 39 // This makes it possible to directly connect the breakout board to the 40 // Arduino. If you use the normal 5V and GND pins on the Arduino, 41 // you can remove these lines. 42 pinMode(groundpin, OUTPUT); 43 pinMode(powerpin, OUTPUT); 44 digitalWrite(groundpin, LOW); 45 digitalWrite(powerpin, HIGH); 46} 47 48void loop() { 49 // print the sensor values: 50 Serial.print(analogRead(xpin)); 51 // print a tab between values: 52 Serial.print("\ "); 53 Serial.print(analogRead(ypin)); 54 // print a tab between values: 55 Serial.print("\ "); 56 Serial.print(analogRead(zpin)); 57 Serial.println(); 58 // delay before next reading: 59 delay(100); 60} 61[Get Code] 62
Downloadable files
Accelerometer - arduino hook up
This is a basic example found in the arduino example list: https://www.arduino.cc/en/Tutorial/ADXL3xx
Accelerometer - arduino hook up

Comments
Only logged in users can leave comments