From 6b0e34540fd39937ee7d7f807a022dd542a81c73 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Tue, 30 Jun 2009 19:30:48 +0000 Subject: [PATCH] --- .../dist/examples/Sensors/ADXL3xx/ADXL3xx.pde | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/build/shared/dist/examples/Sensors/ADXL3xx/ADXL3xx.pde b/build/shared/dist/examples/Sensors/ADXL3xx/ADXL3xx.pde index 41fc69ed2..0d9e15abd 100644 --- a/build/shared/dist/examples/Sensors/ADXL3xx/ADXL3xx.pde +++ b/build/shared/dist/examples/Sensors/ADXL3xx/ADXL3xx.pde @@ -1,28 +1,39 @@ -// 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 -// Breakout Board Pinout -// 0: self test -// 1: z-axis -// 2: y-axis -// 3: x-axis -// 4: ground -// 5: vcc +/* + 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 -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) + 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 @@ -37,11 +48,15 @@ void setup() void loop() { + // print the sensor values: Serial.print(analogRead(xpin)); - Serial.print(" "); + // print a tab between values: + Serial.print("\t"); Serial.print(analogRead(ypin)); - Serial.print(" "); + // print a tab between values: + Serial.print("\t"); Serial.print(analogRead(zpin)); Serial.println(); - delay(1000); + // delay before next reading: + delay(100); }