当前位置: 首页>>代码示例>>Java>>正文


Java GpioPinDigitalOutput.high方法代码示例

本文整理汇总了Java中com.pi4j.io.gpio.GpioPinDigitalOutput.high方法的典型用法代码示例。如果您正苦于以下问题:Java GpioPinDigitalOutput.high方法的具体用法?Java GpioPinDigitalOutput.high怎么用?Java GpioPinDigitalOutput.high使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.pi4j.io.gpio.GpioPinDigitalOutput的用法示例。


在下文中一共展示了GpioPinDigitalOutput.high方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendPowerPinSwitch

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
private boolean sendPowerPinSwitch(MessageParsedInfo messageParsedInfo) {
	
	int pinNum = (Integer)messageParsedInfo.getParsedValues()[0];
	int power  = (Integer)messageParsedInfo.getParsedValues()[1];
			
	GpioPinDigitalOutput pin = (GpioPinDigitalOutput)getPin(pinNum);
	pin.setMode(PinMode.DIGITAL_OUTPUT);
	
	if(power == IProtocol.LOW) {
		pin.low();
	} else {
		pin.high();
	}
	
	return true;
}
 
开发者ID:Ardulink,项目名称:Ardulink-1,代码行数:17,代码来源:RaspberryPIConnection.java

示例2: write

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
@Override
public Integer write(Integer endereco, Integer comando) {
	Integer resultante = null;
	
	GpioPinDigitalOutput pino = (GpioPinDigitalOutput) this.pinos.get(endereco);
	switch(comando){
	case 1:
		pino.high();
		resultante = 1;
		break;
	case 0:
		pino.low();
		resultante = 0;
		break;
	case 2:
		pino.toggle();
		if(pino.isHigh()){
			resultante = 1;
		}else{
			resultante = 0;
		}
		break;
	}
	return resultante;
}
 
开发者ID:Gunisalvo,项目名称:Grappa,代码行数:26,代码来源:RaspberryPi4J.java

示例3: run

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
@Override
public void run() {
	while (!stopThread) {
		for (GpioPinDigitalOutput led : listLed) {
			if (ledStatus) {
				led.high();
			} else {
				led.low();
			}
		}
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		ledStatus = !ledStatus;
	}
	stopThread = false;
}
 
开发者ID:benoitm76,项目名称:F1TelemetryOnRpi,代码行数:20,代码来源:BlinkRunnable.java

示例4: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
    final GpioController gpio = GpioFactory.getInstance();	//get the reference to pin numbers
    GpioPinDigitalOutput pinDir = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "Direction (BCM 23)", PinState.LOW);
    GpioPinDigitalOutput pinStep = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "Step (BCM 25)", PinState.LOW);
    GpioPinDigitalOutput pinEnable = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_29, "~Enable (BCM 21)", PinState.HIGH);

    while (System.in.available() == 0) {
        pinEnable.high();
        Thread.sleep(1000);
        pinEnable.low();
        Thread.sleep(1000);
    }
}
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:14,代码来源:PinTest.java

示例5: switchDigitalPin

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
@Override
public long switchDigitalPin(DigitalPin digitalPin, boolean value)
		throws IOException {
	GpioPinDigitalOutput pin = (GpioPinDigitalOutput) getOrCreate(
			digitalPin.pinNum(), DIGITAL_OUTPUT);
	if (value) {
		pin.high();
	} else {
		pin.low();
	}
	return MessageIdHolders.NO_ID.getId();
}
 
开发者ID:Ardulink,项目名称:Ardulink-2,代码行数:13,代码来源:PiLink.java

示例6: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	// get a handle to the GPIO controller
	final GpioController gpio = GpioFactory.getInstance();

	final GpioPinDigitalOutput pinA = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "PinA");
	final GpioPinDigitalOutput pinB = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, "PinB");
	final GpioPinDigitalOutput pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "PinE");

	System.out.println("rotate motor clock-wise for 3 seconds");
	pinA.high();
	pinB.low();
	pinE.high();

	// wait 3 seconds
	Thread.sleep(3000);

	System.out.println("rotate motor in oposite derection for 6 seconds");
	pinA.low();
	pinB.high();

	// wait 6 seconds
	Thread.sleep(6000);

	// stop motor
	System.out.println("Stopping motor");
	pinE.low();

	gpio.shutdown();
}
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:30,代码来源:ControlOneMotorDirection.java

示例7: ToggleLedNo

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
private void ToggleLedNo(int number, String state, boolean isFromInput) {
    // GpioController  gpio = GpioFactory.getInstance();
    GpioPinDigitalOutput pin = null;

    int portOut = number;
    if (isFromInput) {
        portOut = getRealOutLed(number);
    }
    pin = pins[portOut];

    if (pin == null) {
        initGpioPinDigitalOutputs();
        pin = pins[number];
    }
    if (pin == null) {
        return;
    }
    if (state.equalsIgnoreCase(ON.get(0))) {
        pin.high();
    } else if (state.equalsIgnoreCase(OFF.get(0))) {
        pin.low();
    }

    //           String usingString=outputPowerCommands[i].get(j)+""+isDoing;
    //      
    //         if(fr!=null)
    //         fr.changeState(usingString);
    if (fr.isSwitchModeSelected) {
        fr.updateManual();
    }

}
 
开发者ID:tsoglani,项目名称:SpeechRaspberrySmartHouse,代码行数:33,代码来源:SH.java

示例8: doGet

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException 
{
    ServletConfig servletConfig = getServletConfig();        
    ServletContext servletContext = servletConfig.getServletContext();
    Object attribute = servletContext.getAttribute(ControlPanelServlet.LIZARD_ENCLOSURE_ID);
    LizardEnclosure enclosure = (LizardEnclosure) attribute;
    GpioPinDigitalOutput humidifierPin = enclosure.humidifierPin;
    
    String parameter = request.getParameter("power");
                                    
    switch(parameter)
    {
        case "on":
        {
            humidifierPin.high();
            break;                
        }
        case "off":
        {
            humidifierPin.low();
            break;
        }
        default:
        {
            System.err.println("The humidifier servlet was called, but not with a valid request: " + parameter);
        }
   }
    
   ServletContext c = getServletContext();
   RequestDispatcher rd = c.getRequestDispatcher("/controls");
   rd.forward(request, response);
}
 
开发者ID:onebeartoe,项目名称:lizard-enclosure,代码行数:35,代码来源:HumidifierServlet.java

示例9: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {

        // START SNIPPET: usage-create-controller-snippet
        // create gpio controller instance
        final GpioController gpio = GpioFactory.getInstance();
        // END SNIPPET: usage-create-controller-snippet

        // START SNIPPET: usage-provision-input-pin-snippet
        // provision gpio pin #02 as an input pin with its internal pull down resistor enabled
        // (configure pin edge to both rising and falling to get notified for HIGH and LOW state
        // changes)
        GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02,             // PIN NUMBER
                                                                     "MyButton",                   // PIN FRIENDLY NAME (optional)
                                                                     PinPullResistance.PULL_DOWN); // PIN RESISTANCE (optional)

        // END SNIPPET: usage-provision-input-pin-snippet
        // START SNIPPET: usage-provision-output-pin-snippet
        // provision gpio pins #04 as an output pin and make sure is is set to LOW at startup
        GpioPinDigitalOutput myLed = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04,   // PIN NUMBER
                                                                   "My LED",           // PIN FRIENDLY NAME (optional)
                                                                   PinState.LOW);      // PIN STARTUP STATE (optional)
        // END SNIPPET: usage-provision-output-pin-snippet

        // START SNIPPET: usage-shutdown-pin-snippet
        // configure the pin shutdown behavior; these settings will be
        // automatically applied to the pin when the application is terminated
        // ensure that the LED is turned OFF when the application is shutdown
        myLed.setShutdownOptions(true, PinState.LOW, PinPullResistance.OFF);
        // END SNIPPET: usage-shutdown-pin-snippet

        // START SNIPPET: usage-control-pin-snippet
        // explicitly set a state on the pin object
        myLed.setState(PinState.HIGH);

        // use convenience wrapper method to set state on the pin object
        myLed.low();
        myLed.high();

        // use toggle method to apply inverse state on the pin object
        myLed.toggle();

        // use pulse method to set the pin to the HIGH state for
        // an explicit length of time in milliseconds
        myLed.pulse(1000);
        // END SNIPPET: usage-control-pin-snippet

        // START SNIPPET: usage-read-pin-snippet
        // get explicit state enumeration for the GPIO pin associated with the button
        PinState myButtonState = myButton.getState();

        // use convenience wrapper method to interrogate the button state
        boolean buttonPressed = myButton.isHigh();
        // END SNIPPET: usage-read-pin-snippet

        // START SNIPPET: usage-register-listener-snippet
        // create and register gpio pin listener
        myButton.addListener(new GpioUsageExampleListener());
        // END SNIPPET: usage-register-listener-snippet

        // START SNIPPET: usage-trigger-snippet
        // create a gpio synchronization trigger on the input pin
        // when the input state changes, also set LED controlling gpio pin to same state
        myButton.addTrigger(new GpioSyncStateTrigger(myLed));
        // END SNIPPET: usage-trigger-snippet

        // keep program running until user aborts (CTRL-C)
        while (true) {
            Thread.sleep(500);
        }

        // 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();   <--- implement this method call if you wish to terminate the Pi4J GPIO controller
    }
 
开发者ID:uwigem,项目名称:uwigem2017,代码行数:75,代码来源:UsageGpioExample.java

示例10: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	// get a handle to the GPIO controller
	final GpioController gpio = GpioFactory.getInstance();

	// init soft PWM pins
	// softPwmCreate(int pin, int value, int range)
	// the range is set like (min=0 ; max=100)
	SoftPwm.softPwmCreate(MOTOR_1_PIN_A, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_1_PIN_B, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_2_PIN_A, 0, 100);
	SoftPwm.softPwmCreate(MOTOR_2_PIN_B, 0, 100);

	// init GPIO pins
	final GpioPinDigitalOutput motor1pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "m1E");
	final GpioPinDigitalOutput motor2pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03, "m2E");

	System.out.println("rotate motor 1 clockwise at 15% speed for 2 seconds");
	motor1pinE.high();
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 15);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 clockwise at 60% speed for 2 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 60);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 clockwise at full speed for 2 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 100);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 1 in oposite direction at 50% speed for 3 seconds");
	SoftPwm.softPwmWrite(MOTOR_1_PIN_A, 0);
	SoftPwm.softPwmWrite(MOTOR_1_PIN_B, 50);

	// wait 3 seconds
	Thread.sleep(3000);

	// disable motor 1
	SoftPwm.softPwmWrite(MOTOR_1_PIN_B, 0);
	motor1pinE.low();

	System.out.println("rotate motor 2 clockwise at 30% speed for 2 seconds");
	motor2pinE.high();
	SoftPwm.softPwmWrite(MOTOR_2_PIN_A, 30);

	// wait 2 seconds
	Thread.sleep(2000);

	System.out.println("rotate motor 2 in oposite direction at 100% speed for 3 seconds");
	SoftPwm.softPwmWrite(MOTOR_2_PIN_A, 0);
	SoftPwm.softPwmWrite(MOTOR_2_PIN_B, 100);

	// wait 3 seconds
	Thread.sleep(3000);

	// disable motor 2
	SoftPwm.softPwmWrite(MOTOR_2_PIN_B, 0);
	motor2pinE.low();

	gpio.shutdown();
}
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:67,代码来源:ControlMotorsDirectionAndSpeed.java

示例11: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	// get a handle to the GPIO controller
	final GpioController gpio = GpioFactory.getInstance();

	final GpioPinDigitalOutput motor1pinA = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "m1A");
	final GpioPinDigitalOutput motor1pinB = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, "m1B");
	final GpioPinDigitalOutput motor1pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "m1E");
	final GpioPinDigitalOutput motor2pinA = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_00, "m2A");
	final GpioPinDigitalOutput motor2pinB = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_02, "m2B");
	final GpioPinDigitalOutput motor2pinE = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03, "m2E");

	System.out.println("rotate both motors clockwise for 3 seconds");
	motor1pinA.high();
	motor1pinB.low();
	motor1pinE.high();
	motor2pinA.high();
	motor2pinB.low();
	motor2pinE.high();

	// wait 3 seconds
	Thread.sleep(3000);

	System.out.println("rotate motor 1 in oposite derection for 3 seconds "
			+ "and motor 2 in oposite direction for 6 seconds");
	motor1pinA.low();
	motor1pinB.high();
	motor2pinA.low();
	motor2pinB.high();

	// wait 3 seconds
	Thread.sleep(3000);
	System.out.println("Stopping motor 1");
	motor1pinE.low();

	// wait 3 seconds
	Thread.sleep(3000);
	System.out.println("Stopping motor 2");
	motor2pinE.low();

	gpio.shutdown();
}
 
开发者ID:JavaTutorialNetwork,项目名称:Tutorials,代码行数:42,代码来源:ControlTwoMotorsDirection.java

示例12: main

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    
    // START SNIPPET: usage-create-controller-snippet
    // create gpio controller instance
    final GpioController gpio = GpioFactory.getInstance();
    // END SNIPPET: usage-create-controller-snippet

    // START SNIPPET: usage-provision-input-pin-snippet
    // provision gpio pin #02 as an input pin with its internal pull down resistor enabled
    // (configure pin edge to both rising and falling to get notified for HIGH and LOW state
    // changes)
    GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_02,             // PIN NUMBER
                                                                 "MyButton",                   // PIN FRIENDLY NAME (optional)
                                                                 PinPullResistance.PULL_DOWN); // PIN RESISTANCE (optional)

    // END SNIPPET: usage-provision-input-pin-snippet
    // START SNIPPET: usage-provision-output-pin-snippet
    // provision gpio pins #04 as an output pin and make sure is is set to LOW at startup
    GpioPinDigitalOutput myLed = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04,   // PIN NUMBER
                                                               "My LED",           // PIN FRIENDLY NAME (optional)
                                                               PinState.LOW);      // PIN STARTUP STATE (optional)
    // END SNIPPET: usage-provision-output-pin-snippet

    // START SNIPPET: usage-shutdown-pin-snippet
    // configure the pin shutdown behavior; these settings will be 
    // automatically applied to the pin when the application is terminated
    // ensure that the LED is turned OFF when the application is shutdown
    myLed.setShutdownOptions(true, PinState.LOW, PinPullResistance.OFF);
    // END SNIPPET: usage-shutdown-pin-snippet
    
    // START SNIPPET: usage-control-pin-snippet
    // explicitly set a state on the pin object
    myLed.setState(PinState.HIGH);

    // use convenience wrapper method to set state on the pin object
    myLed.low();
    myLed.high();

    // use toggle method to apply inverse state on the pin object
    myLed.toggle();

    // use pulse method to set the pin to the HIGH state for
    // an explicit length of time in milliseconds
    myLed.pulse(1000);
    // END SNIPPET: usage-control-pin-snippet

    // START SNIPPET: usage-read-pin-snippet
    // get explicit state enumeration for the GPIO pin associated with the button
    PinState myButtonState = myButton.getState();

    // use convenience wrapper method to interrogate the button state
    boolean buttonPressed = myButton.isHigh();
    // END SNIPPET: usage-read-pin-snippet

    // START SNIPPET: usage-register-listener-snippet
    // create and register gpio pin listener
    myButton.addListener(new GpioUsageExampleListener());
    // END SNIPPET: usage-register-listener-snippet

    // START SNIPPET: usage-trigger-snippet
    // create a gpio synchronization trigger on the input pin
    // when the input state changes, also set LED controlling gpio pin to same state
    myButton.addTrigger(new GpioSyncStateTrigger(myLed));
    // END SNIPPET: usage-trigger-snippet

    // keep program running until user aborts (CTRL-C)
    for (;;) {
        Thread.sleep(500);
    }
    
    // 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();   <--- implement this method call if you wish to terminate the Pi4J GPIO controller                
}
 
开发者ID:iot-labs,项目名称:communication,代码行数:75,代码来源:UsageGpioExample.java

示例13: processLedString

import com.pi4j.io.gpio.GpioPinDigitalOutput; //导入方法依赖的package包/类
protected boolean processLedString(String input) {
    // get a handle to the GPIO controller
    // GpioController  gpio = GpioFactory.getInstance();
    boolean found = false;
    GpioPinDigitalOutput pin;
    String isDoing = "off"; // creating the pin with parameter PinState.HIGH
    // will instantly power up the pin
    for (int i = 0; i < outputCommands.length; i++) {

        for (int j = 0; j < outputCommands[i].size(); j++) {
            if (input.startsWith(outputCommands[i].get(j))) {
                isDoing = input.replace(outputCommands[i].get(j), "").replaceAll(" ", "");
            } else {
                try {
                    String firstWord = input.split(" ")[0];
                    if (OFFAtTheStartOfSentence.contains(firstWord)) {
                        isDoing = "off";
                        input = input.substring((firstWord + " ").length() + 1, input.length());
                    } else if (ONAtTheStartOfSentence.contains(firstWord)) {
                        isDoing = "on";
                        input = input.substring((firstWord + " ").length() + 1, input.length());

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (input.startsWith(outputCommands[i].get(j))) {
                found = true;

                pin = pins[i];
                isDoing = input.replace(outputCommands[i].get(j), "").replaceAll(" ", "");
                if (ON.contains(isDoing)) {
                    pin.high();
                } else if (OFF.contains(isDoing)) {
                    pin.low();
                }
                if (fr.isSwitchModeSelected) {
                    fr.updateManual();
                }
                break;

            }

        }
    }

    //        pin.high();
    //        System.out.println("light is: ON");
    //
    //        // wait 2 seconds
    //        Thread.sleep(2000);
    //
    //        // turn off GPIO 1
    //        pin.low();
    //        System.out.println("light is: OFF");
    //
    //        // wait 1 second
    //        Thread.sleep(1000);
    //
    //        // turn on GPIO 1 for 1 second and then off
    //        System.out.println("light is: ON for 1 second");
    //        pin.pulse(1000, true);
    //
    //        // release the GPIO controller resources
    //   gpio.shutdown();
    return found;
}
 
开发者ID:tsoglani,项目名称:SpeechRaspberrySmartHouse,代码行数:69,代码来源:SH.java


注:本文中的com.pi4j.io.gpio.GpioPinDigitalOutput.high方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。