I am trying to create something which uses Charlieplexing, and to use it, I need to be able to turn GPIO Pins to and from different states (Low, High and Input) from what I understand from this video: http://www.youtube.com/watch?v=ECXk95qYZu8.

To make a pin low (according to this), I would do:

final GpioController gpio = GpioFactory.getInstance();
GpioPinDigitalOutput myLed = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04,PinState.LOW);

or then myLed.low(); and likewise with High.

The problem is I don't think I can change the Pin's state to "Input". This says that I would have needed to create the variable as an GpioPinDigitalInput, not an GpioPinDigitalOutput.

Does anyone know how I can change a pin's state from High or Low to Input and vica-versa? Will "re-declaring" the variable work?


1 Answer 1


I used a GpioPinDigitalMultipurpose. More info can be found here.

One can then do:

// Provisions the pin.
GpioPinDigitalMultipurpose mypin = gpio.provisionDigitalMultipurposePin(RaspiPin.GPIO_04, PinMode.DIGITAL_INPUT);

// Sets it as an Output pin.

// Sets the state to "high".

// Sets the state to "low".

// Sets it as an Input pin.
  • 1
    why not use GpioPinDigitalMultipurpose for every in then? does it have some performance implications? Commented Dec 26, 2015 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.