Search in sources :

Example 1 with PWMOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.PWMOutputChannel in project java-bowler by NeuronRobotics.

the class PWMTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    PWMOutputChannel pwm = new PWMOutputChannel(dyio.getChannel(4));
    // Loop 10 times setting the pwm output
    float time = 5;
    for (int i = 0; i < 10; i++) {
        System.out.println("Moving.");
        // Set the duty cycle to either 100% or 50%
        int pos = ((i % 2 == 0) ? 100 : 50);
        pwm.setValue(pos);
        // pause between cycles so that the changes are visible
        try {
            Thread.sleep((long) (time * 1000));
        } catch (InterruptedException e) {
        }
    }
    dyio.disconnect();
    System.exit(0);
}
Also used : DyIO(com.neuronrobotics.sdk.dyio.DyIO) PWMOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.PWMOutputChannel)

Aggregations

DyIO (com.neuronrobotics.sdk.dyio.DyIO)1 PWMOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.PWMOutputChannel)1