java: Added java examples for some sensors

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Stefan Andritoiu
2015-10-02 17:31:43 +03:00
committed by Mihai Tudor Panu
parent 9d63545d44
commit 5ff625eaf4
24 changed files with 1187 additions and 28 deletions

View File

@ -23,29 +23,30 @@
*/
public class A110XSample {
static {
try {
System.loadLibrary("javaupm_a110x");
} catch (UnsatisfiedLinkError e) {
}catch (UnsatisfiedLinkError e) {
System.err.println("error in loading native library");
System.exit(-1);
}
}
public static void main(String argv[]) throws InterruptedException {
//! [Interesting]
// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X a110x = new upm_a110x.A110X(2);
while(true) {
if(a110x.magnetDetected()) {
System.out.println("magnet detected...");
}
else {
System.out.println("magnet not detected...");
}
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// Instantiate an A110X sensor on digital pin D2
upm_a110x.A110X hall = new upm_a110x.A110X(2);
// check every second for the presence of a magnetic field (south polarity)
while(true){
if(hall.magnetDetected())
System.out.println("Magnet (south polarity) detected.");
else
System.out.println("No magnet detected.");
Thread.sleep(1000);
}
//! [Interesting]
//! [Interesting]
}
}
}