當前位置: 首頁>>代碼示例>>Java>>正文


Java GpioController.provisionPwmOutputPin方法代碼示例

本文整理匯總了Java中com.pi4j.io.gpio.GpioController.provisionPwmOutputPin方法的典型用法代碼示例。如果您正苦於以下問題:Java GpioController.provisionPwmOutputPin方法的具體用法?Java GpioController.provisionPwmOutputPin怎麽用?Java GpioController.provisionPwmOutputPin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.pi4j.io.gpio.GpioController的用法示例。


在下文中一共展示了GpioController.provisionPwmOutputPin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: provisionPwmOutputs

import com.pi4j.io.gpio.GpioController; //導入方法依賴的package包/類
private static GpioPinPwmOutput[] provisionPwmOutputs(final PCA9685GpioProvider gpioProvider) {
    GpioController gpio = GpioFactory.getInstance();
    GpioPinPwmOutput myOutputs[] = {
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_00, "Pulse 00"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_01, "Pulse 01"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_02, "Pulse 02"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_03, "Pulse 03"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_04, "Pulse 04"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_05, "Pulse 05"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_06, "Pulse 06"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_07, "Pulse 07"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_08, "Pulse 08"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_09, "Pulse 09"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_10, "Always ON"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_11, "Always OFF"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_12, "Servo pulse MIN"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_13, "Servo pulse NEUTRAL"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_14, "Servo pulse MAX"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_15, "not used")};
    return myOutputs;
}
 
開發者ID:uwigem,項目名稱:uwigem2017,代碼行數:22,代碼來源:PCA9685GpioExample.java

示例2: provisionPwmOutputs

import com.pi4j.io.gpio.GpioController; //導入方法依賴的package包/類
private GpioPinPwmOutput[] provisionPwmOutputs(final PCA9685GpioProvider gpioProvider) {
    GpioController gpio = GpioFactory.getInstance();
    GpioPinPwmOutput myOutputs[] = {
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_00, "Servo 00"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_01, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_02, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_03, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_04, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_05, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_06, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_07, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_08, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_09, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_10, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_11, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_12, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_13, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_14, "not used"),
            gpio.provisionPwmOutputPin(gpioProvider, PCA9685Pin.PWM_15, "not used")};
    return myOutputs;
}
 
開發者ID:uwigem,項目名稱:uwigem2017,代碼行數:22,代碼來源:PCA9685GpioServoExample.java

示例3: Motor

import com.pi4j.io.gpio.GpioController; //導入方法依賴的package包/類
public Motor(Pin pwm, Pin direction, Pin enable) {
	GpioController gpio = GpioFactory.getInstance();

	Gpio.pwmSetMode(PWM_MODE_MS);
	Gpio.pwmSetRange(MAX_SPEED);
	Gpio.pwmSetClock(2);

	pwmPin = gpio.provisionPwmOutputPin(pwm, "pwm");
	pwmPin.setPwmRange(MAX_SPEED);

	directionPin = gpio.provisionDigitalOutputPin(direction, "direction");
	enablePin = gpio.provisionDigitalOutputPin(enable, "enable", PinState.LOW);
}
 
開發者ID:gaelblondelle,項目名稱:PSysRoverInitialContrib,代碼行數:14,代碼來源:Motor.java

示例4: main

import com.pi4j.io.gpio.GpioController; //導入方法依賴的package包/類
/**
 * @param args the command line arguments
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException, PlatformAlreadyAssignedException {

    // ####################################################################
    //
    // since we are not using the default Raspberry Pi platform, we should
    // explicitly assign the platform as the BananaPi platform.
    //
    // ####################################################################
    PlatformManager.setPlatform(Platform.BANANAPI);

    // create Pi4J console wrapper/helper
    // (This is a utility class to abstract some of the boilerplate code)
    final Console console = new Console();

    // print program title/header
    console.title("<-- The Pi4J Project -->", "PWM Example");

    // allow for user to exit program using CTRL-C
    console.promptForExit();

    // create GPIO controller instance
    GpioController gpio = GpioFactory.getInstance();

    // ####################################################################
    //
    // When provisioning a pin, use the BananaPiPin class.
    //
    // ####################################################################

    // the BananaPi supports a single hardware PWM pin on GPIO_07
    GpioPinPwmOutput pwm = gpio.provisionPwmOutputPin(BananaPiPin.GPIO_07);

    // set the PWM rate to 500
    pwm.setPwm(500);
    console.println("PWM rate is: " + pwm.getPwm());

    console.println("Press ENTER to set the PWM to a rate of 250");
    System.console().readLine();

    // set the PWM rate to 250
    pwm.setPwm(250);
    console.println("PWM rate is: " + pwm.getPwm());


    console.println("Press ENTER to set the PWM to a rate to 0 (stop PWM)");
    System.console().readLine();

    // set the PWM rate to 0
    pwm.setPwm(0);
    console.println("PWM rate is: " + pwm.getPwm());

    // stop all GPIO activity/threads by shutting down the GPIO controller
    // (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
    gpio.shutdown();
}
 
開發者ID:uwigem,項目名稱:uwigem2017,代碼行數:60,代碼來源:PwmExample.java


注:本文中的com.pi4j.io.gpio.GpioController.provisionPwmOutputPin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。