The ADXL335 is a small, thin, low-power, 3-axis accelerometer with signal conditioned voltage outputs. It measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (1.8V to 3.6V) |
2 | XOUT | X-axis output |
3 | YOUT | Y-axis output |
4 | ZOUT | Z-axis output |
5 | GND | Ground connection |
6 | ST | Self-test |
Powering the Device:
Reading the Outputs:
Calibration:
// Include the Arduino core library
#include <Arduino.h>
// Define the analog pins connected to the accelerometer
const int xPin = A0;
const int yPin = A1;
const int zPin = A2;
void setup() {
// Initialize the serial communication
Serial.begin(9600);
}
void loop() {
// Read the raw values from the accelerometer
int xRaw = analogRead(xPin);
int yRaw = analogRead(yPin);
int zRaw = analogRead(zPin);
// Convert the raw values to 'g' values
float xG = (xRaw - 338.0) * (3.0 / 1023.0);
float yG = (yRaw - 338.0) * (3.0 / 1023.0);
float zG = (zRaw - 338.0) * (3.0 / 1023.0);
// Print the acceleration 'g' values
Serial.print("X: ");
Serial.print(xG);
Serial.print("g, Y: ");
Serial.print(yG);
Serial.print("g, Z: ");
Serial.print(zG);
Serial.println("g");
// Delay before the next reading
delay(100);
}
Note: The values 338.0 and 3.0/1023.0 in the code are based on a typical sensitivity and zero-g offset. These values should be calibrated for each ADXL335 device used.
FAQs:
Q: Can the ADXL335 measure rotation?
Q: What is the purpose of the self-test pin?
Q: How do I convert the analog readings to 'g' values?
Remember, this documentation is a starting point. For more detailed information, consult the ADXL335 datasheet and application notes provided by the manufacturer.