2015-10-08 14:30:12 +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-10-08 14:30:12 +03:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-10-08 14:30:12 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//NOT TESTED!!!
|
2018-02-27 12:12:09 -08:00
|
|
|
public class StepMotor_Example {
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-12-21 14:57:04 -08:00
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
|
// ! [Interesting]
|
|
|
|
|
upm_stepmotor.StepMotor sensor = new upm_stepmotor.StepMotor(2, 3);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-12-21 14:57:04 -08:00
|
|
|
while (true) {
|
|
|
|
|
System.out.println("One complete rotation forward and back at 60 rpm.");
|
|
|
|
|
sensor.setSpeed(60);
|
|
|
|
|
sensor.stepForward(200);
|
|
|
|
|
Thread.sleep(1000);
|
2015-12-22 15:20:30 -08:00
|
|
|
sensor.stepBackward(200);
|
2015-12-21 14:57:04 -08:00
|
|
|
Thread.sleep(1000);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-12-21 14:57:04 -08:00
|
|
|
System.out.println("One complete rotation forward and back at 150 rpm.");
|
|
|
|
|
sensor.setSpeed(150);
|
|
|
|
|
sensor.stepForward(200);
|
|
|
|
|
Thread.sleep(1000);
|
2015-12-22 15:20:30 -08:00
|
|
|
sensor.stepBackward(200);
|
2015-12-21 14:57:04 -08:00
|
|
|
Thread.sleep(1000);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-12-21 14:57:04 -08:00
|
|
|
System.out.println("One complete rotation forward and back at 300 rpm.");
|
|
|
|
|
sensor.setSpeed(300);
|
|
|
|
|
sensor.stepForward(200);
|
|
|
|
|
Thread.sleep(1000);
|
2015-12-22 15:20:30 -08:00
|
|
|
sensor.stepBackward(200);
|
2015-12-21 14:57:04 -08:00
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
// ! [Interesting]
|
|
|
|
|
}
|
|
|
|
|
}
|