top of page

Accelerometer Functioning

  • projectsilversteps
  • Oct 28, 2015
  • 1 min read

Today

Today Karly was able to connect and get the accelerometer to function. The ouput of the Arduino Uno reading the accelerometer is shown above. The Arduino Uno samples the x,y,z analog pins and outputs the readings in terms of m/s^2. Below shows the circuit that was constructed.

The specific connections are shown in the diagram below. The ADXL 335 is powered by the 5V pin on the Arduino Uno. It is also grounded on the Arduino by connecting to the GND pin. The X, Y, and Z pins provide an analog output and are connected to the A0, A1, and A2 pins respectively. Finally, the analog reference pin is connected to the 3V pin on the ADXL335 to provide a base reference to compare the changes in the voltages that are sensed by the X,Y, and Z pins.

The Arduino code used to produce and output is shown below:

/

/**************************************************************************/

/*!

Initialize

*/

/**************************************************************************/

#include <SPI.h>

//connect 3.3v to AREF

int input[3];

double output[3];

void setup() {

Serial.begin(9600);

}

/**************************************************************************/

/*!

Constantly checks and maps ADXL335

*/

/**************************************************************************/

void loop() {

analogReference(EXTERNAL); //connect 3.3v to AREF

//input is (x,y,z) acceleration with values from 0 to 1023

input[0] = analogRead(A0);

input[1] = analogRead(A1);

input[2] = analogRead(A2);

//output maps input from -3 G's to +3 G's

output[0] = input[0] / 1023.0 * 6.0 - 3.0;

output[1] = input[1] / 1023.0 * 6.0 - 3.0;

output[2] = input[2] / 1023.0 * 6.0 - 3.0;

String out = "(" + String(output[0]) + "," + String(output[1]) + "," + String(output[2]) + ")";

delay(8);

}


 
 
 

Comments


Featured Posts
Recent Posts
Archive
bottom of page