The AITrip ADXL335 GY-61 is a small, thin, low-power, complete 3-axis accelerometer with signal-conditioned voltage outputs. It measures acceleration with a minimum full-scale range of ±3g. It can measure both dynamic acceleration (e.g., vibration) and static acceleration (e.g., gravity).
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (1.8V - 3.6V DC) |
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 |
// 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 serial communication at 9600 baud rate
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) / 100.0; // Replace 338.0 with your calibrated zero-g value
float yG = (yRaw - 338.0) / 100.0; // Replace 338.0 with your calibrated zero-g value
float zG = (zRaw - 338.0) / 100.0; // Replace 338.0 with your calibrated zero-g value
// Print the acceleration 'g' values to the Serial Monitor
Serial.print("X: ");
Serial.print(xG);
Serial.print("g, Y: ");
Serial.print(yG);
Serial.print("g, Z: ");
Serial.print(zG);
Serial.println("g");
// Delay for a bit to avoid spamming the Serial Monitor
delay(100);
}
analogRead
function is used to read the voltage output from the accelerometer.Serial.print
statements output the acceleration values to the Serial Monitor.delay
function is used to slow down the loop for readability.Q: Can the ADXL335 measure rotation?
Q: What is the sensitivity of the sensor?
Q: How do I convert the analog readings to 'g' values?
Remember to always handle electronic components with care and follow proper ESD safety procedures.