| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Accelerometer Test Code

Page history last edited by Akil Srinivasan 12 years, 9 months ago

 

/*

 ADXL3xx

 

 Reads an Analog Devices ADXL3xx accelerometer and communicates the

 acceleration to the computer.  The pins used are designed to be easily

 compatible with the breakout boards from Sparkfun, available from:

 http://www.sparkfun.com/commerce/categories.php?c=80

 

 http://www.arduino.cc/en/Tutorial/ADXL3xx

 

 The circuit:

 analog 0: accelerometer self test

 analog 1: z-axis

 analog 2: y-axis

 analog 3: x-axis

 

 created 2 Jul 2008

 by David A. Mellis

 modified 4 Sep 2010

 by Tom Igoe 

 

 This example code is in the public domain.

 

*/

 

// these constants describe the pins. They won't change:

const int xpin = A3;                  // x-axis of the accelerometer

const int ypin = A2;                  // y-axis

const int zpin = A1;                  // z-axis (only on 3-axis models)

 

void setup()

{

  // initialize the serial communications:

  Serial.begin(9600);

}

 

void loop()

{

  // print the sensor values:

  Serial.print(analogRead(xpin));

  // print a tab between values:

  Serial.print("\t");

  Serial.print(analogRead(ypin));

  // print a tab between values:

  Serial.print("\t");

  Serial.print(analogRead(zpin));

  Serial.println();

  // delay before next reading:

  delay(100);

}

 

Comments (0)

You don't have permission to comment on this page.