2015-09-08 21:58:36 +03:00
|
|
|
/*
|
|
|
|
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-09-08 21:58:36 +03:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-09-08 21:58:36 +03:00
|
|
|
*/
|
|
|
|
|
2015-10-08 14:30:12 +03:00
|
|
|
//NOT TESTED!!!
|
2018-02-27 12:12:09 -08:00
|
|
|
public class Adxl345_Example {
|
2015-08-05 19:46:01 +03:00
|
|
|
|
2015-10-08 14:30:12 +03:00
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
// ! [Interesting]
|
|
|
|
short[] val;
|
|
|
|
float[] accel;
|
2015-08-05 19:46:01 +03:00
|
|
|
|
2015-10-08 14:30:12 +03:00
|
|
|
// Note: Sensor only works at 3.3V on the Intel Edison with Arduino
|
|
|
|
// breakout
|
|
|
|
upm_adxl345.Adxl345 sensor = new upm_adxl345.Adxl345(0);
|
2015-08-05 19:46:01 +03:00
|
|
|
|
2015-10-08 14:30:12 +03:00
|
|
|
while (true) {
|
|
|
|
sensor.update();
|
|
|
|
val = sensor.getRawValues();
|
|
|
|
accel = sensor.getAcceleration();
|
|
|
|
|
|
|
|
System.out.println("Current scale: " + sensor.getScale());
|
2015-11-03 17:40:37 +02:00
|
|
|
System.out.println("Raw Values: X: " + val[0] + " Y: " + val[1] + " Z: " + val[2]);
|
|
|
|
System.out.println("Acceleration: X: " + accel[0] + "g Y: " + accel[1] + "g Z: "
|
|
|
|
+ accel[2] + "g");
|
2015-10-08 14:30:12 +03:00
|
|
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
}
|
|
|
|
// ! [Interesting]
|
|
|
|
}
|
|
|
|
}
|