The ADXL335 is a small, thin, low-power triple-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. Common applications include gaming devices, mobile devices, sports and health devices, and system orientation detection.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (1.8V to 3.6V) |
2 | X-OUT | Analog voltage output for X-axis |
3 | Y-OUT | Analog voltage output for Y-axis |
4 | Z-OUT | Analog voltage output for Z-axis |
5 | GND | Ground reference for the power supply |
6 | ST | Self-test pin (leave unconnected if not used) |
To use the ADXL335 with a microcontroller like the Arduino UNO, follow these steps:
Before using the accelerometer, it is important to calibrate it to ensure accurate readings. This involves reading the outputs at a known orientation (e.g., lying flat) and adjusting the readings to account for zero-g bias and sensitivity.
// 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 analog values from the accelerometer
int xVal = analogRead(xPin);
int yVal = analogRead(yPin);
int zVal = analogRead(zPin);
// Convert the analog values to 'g' values
float xG = ((float)xVal - 341.5) / 68.5; // 341.5 and 68.5 are calibration values
float yG = ((float)yVal - 341.5) / 68.5; // Replace with your calibrated values
float zG = ((float)zVal - 341.5) / 68.5;
// Print the results
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);
}
Q: Can the ADXL335 measure rotation? A: No, the ADXL335 measures linear acceleration. For rotation, you would need a gyroscope.
Q: What is the purpose of the self-test pin? A: The self-test pin is used to verify the functionality of the accelerometer. When activated, it applies a known force to the sensor for testing purposes.
Q: How do I convert the analog readings to 'g' values? A: The analog readings can be converted to 'g' values by first subtracting the zero-g bias level and then dividing by the sensitivity. Calibration is necessary to determine the exact values for these calculations.
Q: Can I use the ADXL335 with a 5V microcontroller? A: Yes, but ensure that the VCC is connected to a 3.3V supply, and use voltage dividers or level shifters for the analog outputs if the microcontroller's analog inputs are not 3.3V tolerant.