B4R Arduino and ADXL335 accelerometer example

The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tiltsensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration.

The user selects the bandwidth of the accelerometer using the CX, CY, and CZ capacitors at the XOUT, YOUT, and ZOUT pins. Bandwidths can be selected to suit the application, with a range of 0.5 Hz to 1600 Hz for X and Y axes, and a range of 0.5 Hz to 550 Hz for the Z axis.

Here is a typical module that makes it easy to work with the ADXL335




Name: ADXL335 module (triaxial accelerometer analog output)
Model: GY-61
Power supply :3-5v
Analog X, Y, Z three-axis output


The following layout shows how to wire the ADXL335 module up to an Arduino UNO





You need to install the following library


Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Public timer1 As Timer
Public adx_xvalue As Float
Public adx_yvalue As Float
Public adx_zvalue As Float
End Sub
Private Sub AppStart
timer1.Enabled = True
End Sub
Private Sub Timer1_Tick
Log("X is: ", adx_xvalue)
Log("Y is: ", adx_yvalue)
Log("Z is: ", adx_zvalue)
End Sub
#if C
#include "ADXL335.h"
ADXL335 adxl335(A0, A1, A2, 3.3);
void setup(B4R::Object* o){
void loop (B4R::Object* o) {
b4r_main::_adx_xvalue =adxl335.readX();
b4r_main::_adx_yvalue =adxl335.readY();
b4r_main::_adx_zvalue =adxl335.readZ();
#End if



X is: -1.6258
Y is: -2.0458
Z is: -1.7403
X is: -1.0790
Y is: -2.2997
Z is: -1.2325
X is: -2.1532
Y is: -1.1180
Z is: -1.3301
X is: -0.9227
Y is: -1.0594
Z is: -1.0079
X is: -0.9422
Y is: -1.4989
Z is: -1.4180
X is: -0.8543
Y is: -1.7528
Z is: -1.7598



The sensor costs under $2

GY-61 ADXL335 Module Triaxial Acceleration Gravity Angle Sensor

Be Sociable, Share!

Comments are closed.