Gibt die Werte des Accelerometers (x, y, z) über die serielle Schnittstelle aus
/*
* Accelerometer ADXL3xx
*
* Reads an Analog Devices ADXL3xx accelerometer and communicates the
* acceleration to the computer.
* The circuit:
* analog 5: x-axis
* analog 4: y-axis
* analog 3: z-axis
*/
int xPin = 5; // x-axis of the accelerometer
int yPin = 4; // y-axis
int zPin = 3; // z-axis (only on 3-axis models)
// to store the sensor data:
int xVal = 0;
int yVal = 0;
int zVal = 0;
void setup() {
Serial.begin(9600); // initialize the serial communications:
}
void loop() {
// read sensor data
xVal = analogRead(xPin);
yVal = analogRead(yPin);
zVal = analogRead(zPin);
// print the sensor values to the Serial Monitor:
Serial.print(xVal);
Serial.print(", ");
Serial.print(yVal);
Serial.print(", ");
Serial.println(zVal);
// delay before next reading:
delay(100);
}
