2015-09-22 19:15:58 +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-22 19:15:58 +03:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-09-22 19:15:58 +03:00
|
|
|
*/
|
|
|
|
|
|
2018-02-27 12:12:09 -08:00
|
|
|
public class ULN200XA_Example {
|
2015-09-22 19:15:58 +03:00
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
2015-10-08 14:30:12 +03:00
|
|
|
// ! [Interesting]
|
2015-09-22 19:15:58 +03:00
|
|
|
// 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);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-09-22 19:15:58 +03:00
|
|
|
uln200xa.setSpeed(5);
|
|
|
|
|
System.out.println("Rotating 1 revolution clockwise.");
|
2016-10-24 16:04:51 -06:00
|
|
|
uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CW);
|
2015-09-22 19:15:58 +03:00
|
|
|
uln200xa.stepperSteps(4096);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-09-22 19:15:58 +03:00
|
|
|
System.out.println("Sleeping for 2 seconds...");
|
|
|
|
|
Thread.sleep(2000);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-09-22 19:15:58 +03:00
|
|
|
System.out.println("Rotating 1/2 revolution counter clockwise.");
|
2016-10-24 16:04:51 -06:00
|
|
|
uln200xa.setDirection(upm_uln200xa.ULN200XA_DIRECTION_T.ULN200XA_DIR_CCW);
|
2015-09-22 19:15:58 +03:00
|
|
|
uln200xa.stepperSteps(2048);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-09-22 19:15:58 +03:00
|
|
|
// turn off the power
|
|
|
|
|
uln200xa.release();
|
2015-10-08 14:30:12 +03:00
|
|
|
// ! [Interesting]
|
|
|
|
|
|
2015-09-22 19:15:58 +03:00
|
|
|
System.out.println("Exiting...");
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 16:04:51 -06:00
|
|
|
}
|