Introduction
The ADXL335 Accelerometer Sensor is a remarkable device that allows electronic projects to detect motion and orientation changes. In this comprehensive guide, we will explore the working principle and capabilities of the ADXL335 sensor. Additionally, we will learn how to How to Interfacing ADXL335 Accelerometer Sensor with Arduino to create a motion-sensing system. By the end of this tutorial, you will have the knowledge and skills to integrate the ADXL335 Accelerometer Sensor into your projects, enabling them to detect movement and tilt. Let’s dive into the world of motion sensing with Arduino and unlock the potential of the ADXL335 Accelerometer Sensor!
Hardware Required
You will require the following Hardware Components for How to Interfacing ADXL335 Accelerometer Sensor with Arduino.
Components | # | Buy From Amazon |
---|---|---|
Arduino UNO | 1 | Buy Now |
ADXL335 Accelerometer Sensor | 1 | Buy Now |
9v DC Adapter (Optional) | 1 | Buy Now |
Jumper Wires | Few | Buy Now |
Breadboard | 1 | Buy Now |
What is ADXL335 Accelerometer Sensor?
The ADXL335 is a three-axis analog accelerometer sensor that measures acceleration in three dimensions: X, Y, and Z. It detects changes in acceleration, enabling the measurement of movement, tilt, and changes in velocity. The sensor is designed to provide analog output proportional to the detected acceleration, allowing for precise motion detection.
Pinout
Pin Configuration
Pin Name | Description |
VCC | Vcc Pin Powers with +5V |
GND | Power Supply Ground |
X-Axis | X-axis Analog Output Pin |
Y-Axis | Y-axis Analog Output Pin |
Z-Axis | Z-axis Analog Output Pin |
Self-Test | ST Self-Test Pin. Controls Self-Test feature |
Specifications
- Three-Axis Detection: The ADXL335 sensor measures acceleration along the X, Y, and Z axes, providing comprehensive motion sensing.
- Analog Output: The sensor outputs analog voltages that correspond to the acceleration in each axis.
- Operating Voltage: The sensor operates within the voltage range compatible with Arduino UNO.
- Sensitivity: The sensitivity of the sensor can be adjusted using onboard capacitors for accurate motion measurement.
Features
- Motion Detection: The ADXL335 sensor accurately detects motion and acceleration changes, making it ideal for tracking movement or orientation changes.
- Tilt Sensing: It can sense the tilt of the device in relation to the Earth’s gravitational field, enabling applications like tilt-controlled devices or games.
- Compact Size: The small form factor of the sensor allows it to be easily integrated into various projects.
Circuit Diagram
The following circuit shows you the connection of the How to Interfacing ADXL335 Accelerometer Sensor with Arduino Please make the connection carefully
Circuit Connections
Arduino | ADXL335 Sensor |
---|---|
+5V | VCC Pin |
GND | GND Pin |
A1 | Z-Axis |
A2 | Y-Axis |
A3 | X-Axis |
Installing Arduino IDE Software
First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow
Installing Libraries
Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow
Code
//For more Projects: www.arduinocircuit.com
#include<math.h>
const int x_out = A1; /* connect x_out of module to A1 of UNO board */
const int y_out = A2; /* connect y_out of module to A2 of UNO board */
const int z_out = A3; /* connect z_out of module to A3 of UNO board */
voidsetup(){
Serial.begin(9600);
}
voidloop(){
int x_adc_value, y_adc_value, z_adc_value;
double x_g_value, y_g_value, z_g_value;
double roll, pitch, yaw;
x_adc_value = analogRead(x_out); /* Digital value of voltage on x_out pin */
y_adc_value = analogRead(y_out); /* Digital value of voltage on y_out pin */
z_adc_value = analogRead(z_out); /* Digital value of voltage on z_out pin */
Serial.print("x = ");
Serial.print(x_adc_value);
Serial.print("\t\t");
Serial.print("y = ");
Serial.print(y_adc_value);
Serial.print("\t\t");
Serial.print("z = ");
Serial.print(z_adc_value);
Serial.print("\t\t");
//delay(100);
x_g_value = ( ( ( (double)(x_adc_value * 5)/1024) - 1.65 ) / 0.330 ); /* Acceleration in x-direction in g units */
y_g_value = ( ( ( (double)(y_adc_value * 5)/1024) - 1.65 ) / 0.330 ); /* Acceleration in y-direction in g units */
z_g_value = ( ( ( (double)(z_adc_value * 5)/1024) - 1.80 ) / 0.330 ); /* Acceleration in z-direction in g units */
roll = ( ( (atan2(y_g_value,z_g_value) * 180) / 3.14 ) + 180 ); /* Formula for roll */
pitch = ( ( (atan2(z_g_value,x_g_value) * 180) / 3.14 ) + 180 ); /* Formula for pitch */
//yaw = ( ( (atan2(x_g_value,y_g_value) * 180) / 3.14 ) + 180 ); /* Formula for yaw */
/* Not possible to measure yaw using accelerometer. Gyroscope must be used if yaw is also required */
Serial.print("Roll = ");
Serial.print(roll);
Serial.print("\t");
Serial.print("Pitch = ");
Serial.print(pitch);
Serial.print("\n\n");
delay(1000);
}
Applications
- Gesture Control: Incorporate the ADXL335 sensor into projects that require gesture-controlled interactions, such as switching on/off devices with a flick of the wrist.
- Gaming: Create motion-sensitive games or interactive applications that respond to the user’s physical movements.
- Robotics: Use the sensor to provide feedback to robotics projects by detecting changes in orientation or acceleration.
- Wearable Tech: Integrate the sensor into wearable devices to track movements or orientations, enabling fitness trackers or smart accessories.
- Vibration Monitoring: Utilize the sensor to detect vibrations in machinery or structures, providing insights into the operational condition.
Conclusion
You have now gained a comprehensive understanding of the ADXL335 Accelerometer Sensor and its applications in motion sensing projects. By interfacing the sensor with Arduino UNO, you can create motion-sensitive devices, games, wearable tech, and more. The sensor’s capability to detect acceleration and tilt opens doors to creative projects that interact with physical movements. Armed with this knowledge, you are ready to integrate the ADXL335 Accelerometer Sensor into your projects, bringing dynamic motion sensing to your electronic creations. So, embrace the power of motion detection and let the ADXL335 sensor add a new dimension of interactivity to your projects