aboutsummaryrefslogtreecommitdiff
path: root/libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-01-06 18:38:03 +0100
committerCristian Maglie <c.maglie@bug.st>2013-01-06 18:38:03 +0100
commitc01bc2b62f76a5d417e5ed13dcb0c047a4f67224 (patch)
tree4703fc452282756f3c40d38f9d41b1a28e0bf0f6 /libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino
parent5f4e55a3d274838388696c3f8130b0f2dc40daf7 (diff)
Merged upcoming 1.0.4 and updated revision log
Diffstat (limited to 'libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino')
-rw-r--r--libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino38
1 files changed, 38 insertions, 0 deletions
diff --git a/libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino b/libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino
new file mode 100644
index 0000000..db5cc93
--- /dev/null
+++ b/libraries/Esplora/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino
@@ -0,0 +1,38 @@
+/*
+ Esplora Accelerometer
+
+ 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
+ the accelerometer values for each axis change when you tilt the board
+ on that axis.
+
+ Created on 22 Dec 2012
+ by Tom Igoe
+
+ This example is in the public domain.
+ */
+
+#include <Esplora.h>
+
+void setup()
+{
+ Serial.begin(9600); // initialize serial communications with your computer
+}
+
+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
+
+ Serial.print("x: "); // print the label for X
+ Serial.print(xAxis); // print the value for the X axis
+ Serial.print("\ty: "); // print a tab character, then the label for Y
+ 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)
+}
+
+