Sunday, August 3, 2014

ADXL 345

Link to ADXL 345 DATASHEET
Connectors for the pins of the ADXL345.
Note: This is not the ADXL345 but it is very similar to it. (A real picture of the sensor could not be obtained) 
How to Connect:
GND to GND
3.3v to 3.3v
X-pin to A3
Y-pin to A2
Z-pin to A1
ST N/A
CODE used for ADXL345:
/*
ADXL345
The circuit: analog 0: accelerometer self test
analog 1: z-axis
analog 2: y-axis
analog 3: x-axis
analog 4: ground
analog 5: vcc
created 2 Jul 2008
by David A. Mellis
modified 27 Jun 2014
by Robert Ortega
This example code is in the public domain.
*/
//
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{
// initialize the serial communications: Serial.begin(9600);
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
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);
}
The ADXL 345 Accelerometer was selected to measure acceleration from motion or shock that the payload would be under the influence of. The ADXL345 comes equipped with a selectable measurement range of ±2g, ±4g, ±8g, or ±16g. 
Future Improvements:
Read the datasheet, which will show what to make of the data the accelerometer is spitting out.

No comments:

Post a Comment