Tutorial.ADXL3xx History

Hide minor edits - Show changes to markup

August 28, 2015, at 02:59 PM by Simone Maiocchi -
Changed lines 1-6 from:
to:
Added line 25:
Changed lines 28-29 from:
to:
Changed line 31 from:
to:
Changed line 58 from:
to:
Changed lines 94-100 from:
to:
Changed lines 103-105 from:
  • Memsic2125 - read a two axis accelerometer
  • Knock - detect knocks/impacts with a piezo element
  • Ping - detect objects with an ultrasonic range finder
to:
  • Knock - Detect knocks with a piezo element.
  • Memsic2125 - Two-axis accelerometer.
  • Ping - Detect objects with an ultrasonic range finder.
July 28, 2015, at 02:38 PM by Simone Maiocchi -
Changed line 96 from:

Last revision 2015/07/28 by SM\\

to:

Last revision 2015/07/28 by SM

July 28, 2015, at 02:37 PM by Simone Maiocchi -
Changed lines 94-96 from:
  • Ping - detect objects with an ultrasonic range finder
to:
  • Ping - detect objects with an ultrasonic range finder


Last revision 2015/07/28 by SM\\

July 28, 2015, at 02:33 PM by Simone Maiocchi -
Changed lines 9-10 from:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer through the serial port.

to:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer through the serial monitor of the Arduino Software (IDE) or another application that receives data over the serial port.

July 07, 2015, at 05:28 PM by Simone Maiocchi -
Changed line 1 from:
to:
July 07, 2015, at 01:04 PM by Simone Maiocchi -
Changed lines 7-8 from:

ADXL3xx Accelerometer

to:

ADXL3xx Accelerometer

Changed line 15 from:

Hardware Required

to:

Hardware Required

Changed lines 19-20 from:

Circuit

to:

Circuit

Changed lines 28-29 from:

Schematic:

to:

Schematic:

Changed line 48 from:

Code

to:

Code

Changed lines 69-70 from:

Data

to:

Data

Changed lines 81-82 from:

See Also:

to:

See Also:

July 07, 2015, at 01:02 PM by Simone Maiocchi -
Changed lines 1-2 from:

Examples > Sensors

to:
Changed line 15 from:

Hardware Required

to:

Hardware Required

Changed lines 19-20 from:

Circuit

to:

Circuit

Changed lines 28-29 from:

Schematic:

to:

Schematic:

Changed line 48 from:

Code

to:

Code

Changed lines 69-70 from:

Data

to:

Data

Changed lines 81-82 from:

See Also:

to:

See Also:

July 04, 2015, at 11:31 AM by Simone Maiocchi -
Changed lines 67-68 from:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

to:

Here are some accelerometer readings collected by positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

July 04, 2015, at 11:27 AM by Simone Maiocchi -
Changed line 47 from:

const int groundpin = 18;

to:

const int groundpin = 18;\\

Changed lines 55-56 from:

digitalWrite(powerpin, HIGH);

to:

digitalWrite(powerpin, HIGH);

July 04, 2015, at 11:25 AM by Simone Maiocchi -
Changed lines 47-49 from:

const int groundpin = 18;
const int powerpin = 19;

to:

const int groundpin = 18; const int powerpin = 19;

Changed lines 52-56 from:
  pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
to:

pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);

July 04, 2015, at 11:23 AM by Simone Maiocchi -
Changed lines 47-49 from:

const int groundpin = 18;
const int powerpin = 19;

to:

const int groundpin = 18;
const int powerpin = 19;

July 04, 2015, at 11:21 AM by Simone Maiocchi -
Changed lines 47-49 from:

const int groundpin = 18; const int powerpin = 19;

to:

const int groundpin = 18;
const int powerpin = 19;

Changed lines 51-55 from:

pinMode(groundpin, OUTPUT); pinMode(powerpin, OUTPUT); digitalWrite(groundpin, LOW); digitalWrite(powerpin, HIGH);

to:
  pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
July 04, 2015, at 11:00 AM by Simone Maiocchi -
Changed line 17 from:

The accelerometer uses very little current, so it can be plugged into your board and run directly off of the output from the digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

to:

The accelerometer uses very little current, so it can be plugged into your board and run directly off of the output from the digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the accelerometer's analog outputs.

Added lines 42-43:

Please, be aware that some accelerometers use 3.3V power supply and might be damaged by 5V. Check the supplier's documentation to find out which is the correct voltage.

Changed lines 56-57 from:

This solution allows the breakout boards from Sparkfun to be connected directly to your Arduino or Genuino board. Different boards may be connected to standard 5V and GND pins. In this latter case, the code may be amended commenting the lines above in the void setup() section.

to:

This solution allows the breakout boards from Sparkfun to be connected directly to your Arduino or Genuino board. Different boards may be connected to standard 5V - or 3.3V -and GND pins. In this latter case, the code may be amended commenting the lines above in the void setup() section.

July 04, 2015, at 10:54 AM by Simone Maiocchi -
Deleted line 45:
Changed lines 49-53 from:

@@ pinMode(groundpin, OUTPUT);

  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);@@
to:

pinMode(groundpin, OUTPUT); pinMode(powerpin, OUTPUT); digitalWrite(groundpin, LOW); digitalWrite(powerpin, HIGH);

July 04, 2015, at 10:51 AM by Simone Maiocchi -
Added line 46:
Changed lines 50-51 from:

@@

  pinMode(groundpin, OUTPUT);
to:

@@ pinMode(groundpin, OUTPUT);

Changed lines 53-55 from:
  digitalWrite(powerpin, HIGH);

@@

to:
  digitalWrite(powerpin, HIGH);@@

This solution allows the breakout boards from Sparkfun to be connected directly to your Arduino or Genuino board. Different boards may be connected to standard 5V and GND pins. In this latter case, the code may be amended commenting the lines above in the void setup() section.

July 04, 2015, at 10:40 AM by Simone Maiocchi -
Added lines 43-55:

The accelerometer connections are defined as constants at the beginning of the sketch, using the two Analog pins 4 and 5 as source of power. This is accomplished using them as Digital I/O pins 18 and 19. If needed, A0 is D14, A1 is D15 and so on.

const int groundpin = 18; const int powerpin = 19;

Setting pin 19 (A5) as HIGH and pin 18 (A4) as LOW provides the 5V with few milliamps needed by the accelerometer to work. @@

  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);

@@

Changed line 58 from:
to:
Changed lines 67-70 from:
Angle-90-80-70-60-50-40-30-20-100102030405060708090
Acceleration662660654642628610589563537510485455433408390374363357355

to:
Angle-90-80-70-60-50-40-30-20-100
Acceleration662660654642628610589563537510

Angle0102030405060708090
Acceleration510485455433408390374363357355
Changed lines 76-82 from:
to:
July 04, 2015, at 10:07 AM by Simone Maiocchi -
Changed lines 5-6 from:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer.

to:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer through the serial port.

Changed line 12 from:
  • Arduino Board
to:
  • Arduino or Genuino Board
Changed line 17 from:

The accelerometer uses very little amperage, so it can be plugged into your Arduino and run directly off of the output from the Arduino's digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

to:

The accelerometer uses very little current, so it can be plugged into your board and run directly off of the output from the digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

May 02, 2012, at 04:04 PM by Scott Fitzgerald -
Changed line 45 from:
to:
November 16, 2011, at 04:19 AM by Scott Fitzgerald -
Changed line 45 from:
to:
September 23, 2010, at 10:41 PM by Christian Cerrito -
Changed lines 3-4 from:

ADXL3xx Accelerometer

to:

ADXL3xx Accelerometer

September 19, 2010, at 10:07 PM by Christian Cerrito -
Changed lines 1-2 from:

Examples > Analog I/O

to:

Examples > Sensors

September 19, 2010, at 08:23 AM by Christian Cerrito -
Added lines 22-23:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

September 18, 2010, at 02:32 AM by Christian Cerrito -
Changed lines 61-64 from:
to:
September 18, 2010, at 02:31 AM by Christian Cerrito -
Changed lines 7-8 from:

This tutorial was built using the breakout boards from Sparkfun. The adafruit accelerometer breakout board also works, though it must be wired differently.

to:

This tutorial was built using the breakout boards from Sparkfun. The adafruit accelerometer breakout board also works, though it must be wired differently.

September 18, 2010, at 02:31 AM by Christian Cerrito -
Changed lines 7-8 from:

This tutorial was built using the breakout boards from Sparkfun. The Ping - detect objects with an ultrasonic range finder]] also works, though the order of the pins is slightly different.

to:

This tutorial was built using the breakout boards from Sparkfun. The adafruit accelerometer breakout board also works, though it must be wired differently.

September 18, 2010, at 02:28 AM by Christian Cerrito -
Changed lines 7-8 from:

This tutorial was built using the breakout boards from Sparkfun. The Adafruit accelerometer breakout board also works, though the order of the pins is slightly different.

to:

This tutorial was built using the breakout boards from Sparkfun. The Ping - detect objects with an ultrasonic range finder]] also works, though the order of the pins is slightly different.

September 18, 2010, at 02:25 AM by Christian Cerrito -
Changed line 58 from:
to:
Changed line 67 from:
  • [[Tutorial/Memsic2125] - read a two axis accelerometer
to:
Changed line 69 from:
  • Ping - detect objects with an ultrasonic range finder
to:
  • Ping - detect objects with an ultrasonic range finder
September 18, 2010, at 02:24 AM by Christian Cerrito -
Changed line 58 from:
to:
Changed lines 60-64 from:
  • delay()

  • WhileLoop - Use a While Loop to calibrate a sensor while a button is being pressed.
  • SwitchCase - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.
  • Array: a variation on the For Loop example that demonstrates how to use an array.
to:
  • analogRead()
  • serial.begin
  • serial.print

  • AnalogInput - Use a potentiometer to control the blinking of an LED.
  • AnalogInOutSerial - read an analog input, map its values, and then use that information to dim or brighten an LED.
  • [[Tutorial/Memsic2125] - read a two axis accelerometer
  • Knock - detect knocks/impacts with a piezo element
  • Ping - detect objects with an ultrasonic range finder
September 18, 2010, at 02:16 AM by Christian Cerrito -
Changed line 17 from:

The accelerometer uses very little amperage, so it can run off the output of the Arduino's digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

to:

The accelerometer uses very little amperage, so it can be plugged into your Arduino and run directly off of the output from the Arduino's digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

September 18, 2010, at 02:14 AM by Christian Cerrito -
Changed lines 53-64 from:
Acceleration662660654642628610589563537510485455433408390374363357355
to:
Acceleration662660654642628610589563537510485455433408390374363357355

See Also:

  • for()
  • digitalWrite()
  • delay()

  • WhileLoop - Use a While Loop to calibrate a sensor while a button is being pressed.
  • SwitchCase - Choose between a number of discrete values in a manner that is the equivalent of using multiples If statements. This example shows how to divide a sensor's range into a set of four bands and to take four different actions depending on which band the result is in.
  • Array: a variation on the For Loop example that demonstrates how to use an array.
September 18, 2010, at 02:13 AM by Christian Cerrito -
Deleted lines 39-43:

An ADXL322 on a Sparkfun breakout board inserted into the analog input pins of an Arduino.

September 18, 2010, at 02:12 AM by Christian Cerrito -
Added lines 19-27:

Schematic:

click the image to enlarge

Changed lines 41-49 from:

Schematic:

click the image to enlarge

to:
September 18, 2010, at 02:12 AM by Christian Cerrito -
Deleted lines 16-26:

Schematic:

click the image to enlarge

An ADXL322 on a Sparkfun breakout board inserted into the analog input pins of an Arduino.

Added lines 31-43:

Schematic:

click the image to enlarge

An ADXL322 on a Sparkfun breakout board inserted into the analog input pins of an Arduino.

September 18, 2010, at 02:10 AM by Christian Cerrito -
Changed lines 11-14 from:
to:

Hardware Required

  • Arduino Board
  • ADXL3xx Accelerometer
September 18, 2010, at 02:08 AM by Christian Cerrito -
Changed lines 20-22 from:

to:

September 18, 2010, at 02:07 AM by Christian Cerrito -
Changed lines 14-15 from:
to:
September 18, 2010, at 02:07 AM by Christian Cerrito -
Changed lines 14-15 from:
to:
September 18, 2010, at 02:05 AM by Christian Cerrito -
Changed lines 14-15 from:
to:
September 18, 2010, at 01:57 AM by Christian Cerrito -
September 18, 2010, at 01:56 AM by Christian Cerrito -
Changed lines 14-15 from:

Attach: ADXL3X_BB.png

to:
September 18, 2010, at 01:54 AM by Christian Cerrito -
Changed lines 14-15 from:
to:

Attach: ADXL3X_BB.png

Changed lines 20-22 from:

to:

September 18, 2010, at 01:53 AM by Christian Cerrito -
Changed lines 5-6 from:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer.

to:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer.

September 16, 2010, at 10:18 PM by Tom Igoe -
Changed line 42 from:
to:
September 16, 2010, at 10:18 PM by Tom Igoe -
Changed line 42 from:
to:
February 24, 2010, at 04:30 AM by Tom Igoe -
Added line 42:
Deleted lines 43-104:
 /*
  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
  analog 4: ground
  analog 5: vcc
  
  created 2 Jul 2008
  by David A. Mellis
  modified 26 Jun 2009
  by Tom Igoe 

 */

 // these constants describe the pins. They won't change:
 const int groundpin = 18;             // analog input pin 4 -- ground
 const int powerpin = 19;              // analog input pin 5 -- voltage
 const int xpin = 3;                   // x-axis of the accelerometer
 const int ypin = 2;                   // y-axis
 const int zpin = 1;                   // z-axis (only on 3-axis models)

 void setup()
 {
   // initialize the serial communications:
   Serial.begin(9600);

   // Provide ground and power by using the analog inputs as normal
   // digital pins.  This makes it possible to directly connect the
   // breakout board to the Arduino.  If you use the normal 5V and
   // GND pins on the Arduino, you can remove these lines.
   pinMode(groundpin, OUTPUT);
   pinMode(powerpin, OUTPUT);
   digitalWrite(groundpin, LOW); 
   digitalWrite(powerpin, HIGH);
 }

 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);
 }
September 23, 2009, at 01:25 AM by David A. Mellis - Pin -> pin
Changed lines 69-73 from:
 const int groundPin = 18;             // analog input pin 4 -- ground
 const int powerPin = 19;              // analog input pin 5 -- voltage
 const int xPin = 3;                   // x-axis of the accelerometer
 const int yPin = 2;                   // y-axis
 const int zPin = 1;                   // z-axis (only on 3-axis models)
to:
 const int groundpin = 18;             // analog input pin 4 -- ground
 const int powerpin = 19;              // analog input pin 5 -- voltage
 const int xpin = 3;                   // x-axis of the accelerometer
 const int ypin = 2;                   // y-axis
 const int zpin = 1;                   // z-axis (only on 3-axis models)
July 05, 2009, at 07:45 PM by Tom Igoe -
Changed lines 40-44 from:

[@

/*

 ADXL3xx
to:
Changed lines 43-56 from:
 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
 analog 4: ground
 analog 5: vcc
to:
 /*
  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
Changed lines 51-96 from:
 created 2 Jul 2008
 by David A. Mellis
 modified 26 Jun 2009
 by Tom Igoe 

  • /

// these constants describe the pins. They won't change: const int groundPin = 18; // analog input pin 4 -- ground const int powerPin = 19; // analog input pin 5 -- voltage const int xPin = 3; // x-axis of the accelerometer const int yPin = 2; // y-axis const int zPin = 1; // z-axis (only on 3-axis models)

void setup() {

  // initialize the serial communications:
  Serial.begin(9600);

  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);

}

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);

}

@]

to:
June 30, 2009, at 09:31 PM by Tom Igoe -
Changed lines 42-47 from:

int groundpin = 18; // analog input pin 4 int powerpin = 19; // analog input pin 5 int xpin = 3; // x-axis of the accelerometer int ypin = 2; // y-axis int zpin = 1; // z-axis (only on 3-axis models)

to:

/*

 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
 analog 4: ground
 analog 5: vcc

 created 2 Jul 2008
 by David A. Mellis
 modified 26 Jun 2009
 by Tom Igoe 

  • /

// these constants describe the pins. They won't change: const int groundPin = 18; // analog input pin 4 -- ground const int powerPin = 19; // analog input pin 5 -- voltage const int xPin = 3; // x-axis of the accelerometer const int yPin = 2; // y-axis const int zPin = 1; // z-axis (only on 3-axis models)

Added line 77:
  // initialize the serial communications:
Changed lines 84-87 from:
  pinMode(groundPin, OUTPUT);
  pinMode(powerPin, OUTPUT);
  digitalWrite(groundPin, LOW); 
  digitalWrite(powerPin, HIGH);
to:
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);
Added line 92:
  // print the sensor values:
Changed lines 94-95 from:
  Serial.print(" ");
to:
  // print a tab between values:
  Serial.print("\t");
Changed lines 97-98 from:
  Serial.print(" ");
to:
  // print a tab between values:
  Serial.print("\t");
Changed lines 101-102 from:
  delay(1000);
to:
  // delay before next reading:
  delay(100);
Added line 104:
Changed line 111 from:
to:
June 30, 2009, at 09:27 PM by Tom Igoe -
June 30, 2009, at 09:24 PM by Tom Igoe -
Added lines 16-22:

Schematic:

click the image to enlarge

June 30, 2009, at 08:04 PM by Tom Igoe -
June 30, 2009, at 07:50 PM by Tom Igoe -
Changed line 34 from:

@@

to:

[@

Changed lines 65-66 from:

@@

to:

@]

June 30, 2009, at 07:49 PM by Tom Igoe -
Changed line 34 from:

[@

to:

@@

Changed lines 65-66 from:

@]

to:

@@

June 30, 2009, at 07:49 PM by Tom Igoe -
Changed lines 69-70 from:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

to:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

June 30, 2009, at 07:48 PM by Tom Igoe -
Changed line 63 from:

delay(1000);

to:
  delay(1000);
Changed lines 69-70 from:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

to:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

June 30, 2009, at 07:48 PM by Tom Igoe -
Changed line 63 from:
  delay(1000);
to:

delay(1000);

June 30, 2009, at 07:48 PM by Tom Igoe -
Changed line 63 from:
  delay(1000);
to:
  delay(1000);
Changed lines 69-70 from:

%color=#CC6600%Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

to:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

June 30, 2009, at 07:47 PM by Tom Igoe -
Changed line 63 from:

%color=#CC6600% delay(1000);

to:
  delay(1000);
Changed lines 69-70 from:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

to:

%color=#CC6600%Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

June 30, 2009, at 07:47 PM by Tom Igoe -
Changed line 63 from:
  delay(1000);
to:

%color=#CC6600% delay(1000);

June 30, 2009, at 07:45 PM by Tom Igoe -
Changed line 35 from:

%color=#CC6600%int groundpin = 18; // analog input pin 4

to:

int groundpin = 18; // analog input pin 4

June 30, 2009, at 07:45 PM by Tom Igoe -
Changed line 35 from:

int groundpin = 18; // analog input pin 4

to:

%color=#CC6600%int groundpin = 18; // analog input pin 4

June 30, 2009, at 07:36 PM by Tom Igoe -
Changed lines 18-20 from:

Pinout for the above configuration:

to:

The accelerometer uses very little amperage, so it can run off the output of the Arduino's digital output pins. To do this, you'll use three of the analog input pins as digital I/O pins, for power and ground to the accelerometer, and for the self-test pin. You'll use the other three analog inputs to read the acclerometer's analog outputs.

Here are the pin connections for the configuration shown above:

Changed line 28 from:
to:
June 30, 2009, at 07:33 PM by Tom Igoe -
Changed lines 5-6 from:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The ADXL3xx outputs the acceleration on each axis as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

to:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicate the acceleration to the a personal computer.

This tutorial was built using the breakout boards from Sparkfun. The Adafruit accelerometer breakout board also works, though the order of the pins is slightly different.

The ADXL3xx outputs the acceleration on each axis as an analog voltage between 0 and 5 volts. To read this, all you need is the analogRead() function.

June 30, 2009, at 07:29 PM by Tom Igoe -
Changed lines 5-6 from:

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The ADXL3xx outputs the acceleration on each axis as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

to:

This tutorial shows you how to read an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The ADXL3xx outputs the acceleration on each axis as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

July 02, 2008, at 09:07 PM by David A. Mellis -
Changed lines 1-2 from:

Examples > Devices

to:

Examples > Analog I/O

July 02, 2008, at 08:58 PM by David A. Mellis -
Changed lines 5-6 from:

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The acceleration on each axis is output as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

to:

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The ADXL3xx outputs the acceleration on each axis as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

July 02, 2008, at 08:57 PM by David A. Mellis -
Changed lines 5-6 from:

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun.

to:

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun. The acceleration on each axis is output as an analog voltage between 0 and 5 volts, which is read by an analog input on the Arduino.

July 02, 2008, at 08:52 PM by David A. Mellis -
Changed lines 62-63 from:

Here are some accelerometer readings from the y-axis of an ADXL322 2g accelerometer. Values should be the same for the other axes, but will vary based on the sensitivity of the device.

to:

Here are some accelerometer readings collected by the positioning the y-axis of an ADXL322 2g accelerometer at various angles from ground. Values should be the same for the other axes, but will vary based on the sensitivity of the device. With the axis horizontal (i.e. parallel to ground or 0°), the accelerometer reading should be around 512, but values at other angles will be different for a different accelerometer (e.g. the ADXL302 5g one).

July 02, 2008, at 08:49 PM by David A. Mellis -
Changed line 64 from:
to:
July 02, 2008, at 08:49 PM by David A. Mellis -
Changed lines 58-66 from:

@]

to:

@]

Data

Here are some accelerometer readings from the y-axis of an ADXL322 2g accelerometer. Values should be the same for the other axes, but will vary based on the sensitivity of the device.

Angle-90-80-70-60-50-40-30-20-100102030405060708090
Acceleration662660654642628610589563537510485455433408390374363357355
July 02, 2008, at 08:43 PM by David A. Mellis -
Changed line 21 from:
to:
July 02, 2008, at 08:43 PM by David A. Mellis -
Changed line 15 from:
to:
July 02, 2008, at 08:42 PM by David A. Mellis -
Added lines 13-14:

Pinout for the above configuration:

Added lines 19-20:

Or, if you're using just the accelerometer:

July 02, 2008, at 08:41 PM by David A. Mellis -
Changed line 13 from:
to:
Changed line 17 from:
to:
July 02, 2008, at 08:40 PM by David A. Mellis -
Changed line 13 from:
to:
Changed line 17 from:
to:
July 02, 2008, at 08:40 PM by David A. Mellis -
Changed line 17 from:
to:
July 02, 2008, at 08:40 PM by David A. Mellis -
Changed line 13 from:
to:
July 02, 2008, at 08:40 PM by David A. Mellis -
Added lines 11-12:

An ADXL322 on a Sparkfun breakout board inserted into the analog input pins of an Arduino.

Changed lines 14-21 from:
Accelerometer PinArduino Pin
Self-TestAnalog Input 0
Z-AxisAnalog Input 1
Y-AxisAnalog Input 2
X-AxisAnalog Input 3
GroundAnalog Input 4
VDDAnalog Input 5
to:
Breakout Board PinSelf-TestZ-AxisY-AxisX-AxisGroundVDD
Arduino Analog Input Pin012345

ADXL3xx PinSelf-TestZOutYOutXOutGroundVDD
Arduino PinNone (unconnected)Analog Input 1Analog Input 2Analog Input 3GND5V
July 02, 2008, at 08:33 PM by David A. Mellis -
Added line 11:
July 02, 2008, at 08:33 PM by David A. Mellis -
Changed lines 11-18 from:
Accelerometer PinArduino Pin
Self-TestAnalog Input 0
Z-AxisAnalog Input 1
Y-AxisAnalog Input 2
X-AxisAnalog Input 3
GroundAnalog Input 4
VDDAnalog Input 5
to:
Accelerometer PinArduino Pin
Self-TestAnalog Input 0
Z-AxisAnalog Input 1
Y-AxisAnalog Input 2
X-AxisAnalog Input 3
GroundAnalog Input 4
VDDAnalog Input 5
July 02, 2008, at 08:32 PM by David A. Mellis -
Added lines 1-52:

Examples > Devices

ADXL3xx Accelerometer

Reads an Analog Devices ADXL3xx series (e.g. ADXL320, ADXL321, ADXL322, ADXL330) accelerometer and communicates the acceleration to the computer. The pins used are designed to be easily compatible with the breakout boards from Sparkfun.

Circuit

Accelerometer PinArduino Pin
Self-TestAnalog Input 0
Z-AxisAnalog Input 1
Y-AxisAnalog Input 2
X-AxisAnalog Input 3
GroundAnalog Input 4
VDDAnalog Input 5

Code

int groundpin = 18;             // analog input pin 4
int powerpin = 19;              // analog input pin 5
int xpin = 3;                   // x-axis of the accelerometer
int ypin = 2;                   // y-axis
int zpin = 1;                   // z-axis (only on 3-axis models)

void setup()
{
  Serial.begin(9600);

  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundPin, OUTPUT);
  pinMode(powerPin, OUTPUT);
  digitalWrite(groundPin, LOW); 
  digitalWrite(powerPin, HIGH);
}

void loop()
{
  Serial.print(analogRead(xpin));
  Serial.print(" ");
  Serial.print(analogRead(ypin));
  Serial.print(" ");
  Serial.print(analogRead(zpin));
  Serial.println();
  delay(1000);
}

Share