mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
java: Added java samples and applied coding style rules to all previous samples
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:

committed by
Mihai Tudor Panu

parent
27f34face1
commit
e34863f223
@ -28,35 +28,35 @@ public class ULN200XASample {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_uln200xa");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
// ! [Interesting]
|
||||
// Instantiate a Stepper motor on a ULN200XA Dual H-Bridge.
|
||||
// Wire the pins so that I1 is pin D8, I2 is pin D9, I3 is pin D10 and
|
||||
// I4 is pin D11
|
||||
upm_uln200xa.ULN200XA uln200xa = new upm_uln200xa.ULN200XA(4096, 8, 9, 10, 11);
|
||||
|
||||
|
||||
uln200xa.setSpeed(5);
|
||||
System.out.println("Rotating 1 revolution clockwise.");
|
||||
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CW);
|
||||
uln200xa.stepperSteps(4096);
|
||||
|
||||
|
||||
System.out.println("Sleeping for 2 seconds...");
|
||||
Thread.sleep(2000);
|
||||
|
||||
|
||||
System.out.println("Rotating 1/2 revolution counter clockwise.");
|
||||
uln200xa.setDirection(upm_uln200xa.ULN200XA.ULN200XA_DIRECTION_T.DIR_CCW);
|
||||
uln200xa.stepperSteps(2048);
|
||||
|
||||
|
||||
// turn off the power
|
||||
uln200xa.release();
|
||||
//! [Interesting]
|
||||
|
||||
// ! [Interesting]
|
||||
|
||||
System.out.println("Exiting...");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user