Tutorial.ADXL3xx History

Hide minor edits - Show changes to markup

June 02, 2010, at 08:23 PM by Equipo Traduccion -
Changed lines 5-6 from:

Este tutorial muesta como leer los dispositivos acelerómetros analógicos de la serie ADXL3xx (ej. ADXL320, ADXL321, ADXL322, ADXL330) y enviar los datos de aceleración al ordenador.

to:

Este tutorial muestra cómo leer los dispositivos acelerómetros analógicos de la serie ADXL3xx (ej. ADXL320, ADXL321, ADXL322, ADXL330) y enviar los datos de aceleración al ordenador.

Changed lines 48-49 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:

Aquí se muestran algunas medidas adquiridas por un acelerómetro a medida que se va modificando la posición del eje Y del un acelerómetro ADXL322 2g respecto del plano horizontal. Los valores para los otros ejes deberían mantenerse iguales a lo largo del experimento, pero podrían variar en función de la sensibilidad del dispositivo. Con el eje horizontal (paralelo al suelo o, lo que es lo mismo, a 0º de inclinación) las lecturas del acelerómetro deberían ser de aproximadamente 512, pero el valor para los demás ángulos dependen del tipo de acelerómetro y su rango de medida (por ejemplo, para un dispositivo ADXL302 5g).

Changed lines 51-52 from:
Angle-90-80-70-60-50-40-30-20-100102030405060708090
Acceleration662660654642628610589563537510485455433408390374363357355
to:
Ángulo-90-80-70-60-50-40-30-20-100102030405060708090
Aceleración662660654642628610589563537510485455433408390374363357355
June 01, 2010, at 10:46 PM by Equipo Traduccion -
Changed lines 1-13 from:

Examples > Analog I/O

ADXL3xx Accelerometer

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.

Circuit

to:

Ejemplos > E/S analógicas

Acelerómetro ADXL3xx

Este tutorial muesta como leer los dispositivos acelerómetros analógicos de la serie ADXL3xx (ej. ADXL320, ADXL321, ADXL322, ADXL330) y enviar los datos de aceleración al ordenador.

Este tutorial fue desarrollado usando la breakout boards de Sparkfun. El Adafruit módulo con el acelerómetro también sirve, aunque el orden de los pins es levemente distinto.

El dispositivo ADXL3xx devuelve datos de aceleración en cada eje en forma de un voltaje en forma analógico etre 0 y 5 voltios. Para leer este voltaje tan sól hace falta hacer uso de la función analogRead().

Circuito

Changed lines 16-19 from:

Schematic:

click the image to enlarge

to:

Esquema:

pincha sobre la imagen para verla a mayor tamaño

Changed lines 23-25 from:

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

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:

el dispositivo ADXL322 incluído en el módulo de Sparkfun debe insertarse en los pins de entrada analógica de la placa Arduino.

El acelerómetro hace uso de un amperaje muy bajo, por lo que puede funcionarThe 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.

Changed lines 27-28 from:

Here are the pin connections for the configuration shown above:

to:

Estos son los pins de conexión para la configuración mencionada anteriormente:

Changed lines 30-34 from:
Breakout Board PinSelf-TestZ-AxisY-AxisX-AxisGroundVDD
Arduino Analog Input Pin012345

Or, if you're using just the accelerometer:

to:
Pins del móduloAutocomprobaciónEje ZEje YEje XNegativoAlimentación
Pins de entrada analógica de Arduino012345

o, si sólo estás usando el acelerómetro:

Changed lines 36-39 from:
ADXL3xx PinSelf-TestZOutYOutXOutGroundVDD
Arduino PinNone (unconnected)Analog Input 1Analog Input 2Analog Input 3GND5V

Code

to:
Pins ADXL3xxAutocomprobaciónSalida ZSalida YSalida XNegativoAlimentación
Pins ArduinoNinguno (desconectado)Entrada analógica 1Entrada analógica 2Entrada analógica 3Negativo5V

Código

Changed lines 46-47 from:

Data

to:

Datos

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