mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
Java:Added example for Flex Sensor and added newly added sensors to the CMakeLists.txt
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
e6ad752a2c
commit
1aa445b74e
@ -101,6 +101,10 @@ add_example(WaterLevelSensor waterlevel)
|
||||
add_example(WT5001Sample wt5001)
|
||||
add_example(YG1006Sample yg1006)
|
||||
add_example(ZFM20Sample zfm20)
|
||||
add_example(Ad8232Example ad8232)
|
||||
add_example(Gp2y0aExample gp2y0a)
|
||||
add_example(Th02Example th02)
|
||||
add_example(FlexSensorExample flex)
|
||||
|
||||
|
||||
add_example_with_path(Jhd1313m1_lcdSample lcd/upm_i2clcd.jar)
|
||||
|
41
examples/java/FlexSensorExample.java
Normal file
41
examples/java/FlexSensorExample.java
Normal file
@ -0,0 +1,41 @@
|
||||
import upm_flex.Flex;
|
||||
|
||||
public class FlexSensorExample {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_flex");
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
//! [Interesting]
|
||||
// The was tested with a Spectra Symbol flex sensor.
|
||||
// We attached a 22K resistor to a breadboard,
|
||||
// with 1 end attached to GND and the other connected to
|
||||
// both the flex sensor and A0.
|
||||
// The flex sensor was connected on 1 pin to the 22K resistor and A0
|
||||
// and on the other pin to 5V.
|
||||
|
||||
// Instantiate a Flex sensor on analog pin A0
|
||||
Flex flex = new Flex(0);
|
||||
while(true){
|
||||
System.out.println("Flex Sensor value is: "+flex.value());
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user