source: rtos_arduino/trunk/arduino_lib/libraries/Esplora/examples/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.1 KB
Line 
1/*
2 Esplora Accelerometer
3
4 This sketch shows you how to read the values from the accelerometer.
5 To see it in action, open the serial monitor and tilt the board. You'll see
6 the accelerometer values for each axis change when you tilt the board
7 on that axis.
8
9 Created on 22 Dec 2012
10 by Tom Igoe
11
12 This example is in the public domain.
13 */
14
15#include <Esplora.h>
16
17void setup()
18{
19 Serial.begin(9600); // initialize serial communications with your computer
20}
21
22void loop()
23{
24 int xAxis = Esplora.readAccelerometer(X_AXIS); // read the X axis
25 int yAxis = Esplora.readAccelerometer(Y_AXIS); // read the Y axis
26 int zAxis = Esplora.readAccelerometer(Z_AXIS); // read the Z axis
27
28 Serial.print("x: "); // print the label for X
29 Serial.print(xAxis); // print the value for the X axis
30 Serial.print("\ty: "); // print a tab character, then the label for Y
31 Serial.print(yAxis); // print the value for the Y axis
32 Serial.print("\tz: "); // print a tab character, then the label for Z
33 Serial.println(zAxis); // print the value for the Z axis
34
35 delay(500); // wait half a second (500 milliseconds)
36}
37
38
Note: See TracBrowser for help on using the repository browser.