2012-12-23 17:55:59 +01:00
|
|
|
/*
|
2013-10-21 09:58:40 +02:00
|
|
|
Esplora Accelerometer
|
|
|
|
|
2012-12-23 17:55:59 +01:00
|
|
|
This sketch shows you how to read the values from the accelerometer.
|
|
|
|
To see it in action, open the serial monitor and tilt the board. You'll see
|
2013-10-21 09:58:40 +02:00
|
|
|
the accelerometer values for each axis change when you tilt the board
|
2012-12-23 17:55:59 +01:00
|
|
|
on that axis.
|
2013-10-21 09:58:40 +02:00
|
|
|
|
2012-12-23 17:55:59 +01:00
|
|
|
Created on 22 Dec 2012
|
|
|
|
by Tom Igoe
|
2013-10-21 09:58:40 +02:00
|
|
|
|
2012-12-23 17:55:59 +01:00
|
|
|
This example is in the public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Esplora.h>
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(9600); // initialize serial communications with your computer
|
2013-10-21 09:58:40 +02:00
|
|
|
}
|
2012-12-23 17:55:59 +01:00
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
int xAxis = Esplora.readAccelerometer(X_AXIS); // read the X axis
|
|
|
|
int yAxis = Esplora.readAccelerometer(Y_AXIS); // read the Y axis
|
|
|
|
int zAxis = Esplora.readAccelerometer(Z_AXIS); // read the Z axis
|
|
|
|
|
2013-10-21 09:58:40 +02:00
|
|
|
Serial.print("x: "); // print the label for X
|
2012-12-23 17:55:59 +01:00
|
|
|
Serial.print(xAxis); // print the value for the X axis
|
2013-10-21 09:58:40 +02:00
|
|
|
Serial.print("\ty: "); // print a tab character, then the label for Y
|
2012-12-23 17:55:59 +01:00
|
|
|
Serial.print(yAxis); // print the value for the Y axis
|
|
|
|
Serial.print("\tz: "); // print a tab character, then the label for Z
|
|
|
|
Serial.println(zAxis); // print the value for the Z axis
|
|
|
|
|
|
|
|
delay(500); // wait half a second (500 milliseconds)
|
|
|
|
}
|
|
|
|
|
|
|
|
|