2

I am trying to get a led working with the Raspberry Pin 3 model B+ with Raspbian. I am using Java Pi4j library this way:

GpioPinDigitalOutput digitalOutputPin = GpioFactory.getInstance().provisionDigitalOutputPin(RaspiPin.GPIO_07);
GpioFactory.getInstance().setState(true, digitalOutPutPin);

It is only working with the Raspipin.GPIO_07 not with others ( Raspipin.GPIO_11, GPIO_13, GPIO_15, GPIO_16, GPIO_18, GPIO_22, GPIO_29, GPIO_31). All pins were already unprovisioned, no exceptions are thrown, but the led is not working with other pin other than the Raspipin.GPIO_07.

What does it mean Raspipin.GPIO_07 is 1-wire pin?.

Im not sure If I am following the right pinout schema. The RaspiPin.GPIO_07 in library is the one labeled as GPIO4 in the picture below am I right? So the RaspiPin.GPIO_11 should be the one labeled in the picture as the GPIO17.

pinout

1

1 Answer 1

4

Welcome. For some reason (historic that made sense at the time I am sure), the Pi4J project followed the WiringPi software for pin layout. To quote their site:

Pi4J (by default) uses an abstract pin numbering scheme to help insulate software from hardware changes. Pi4J implements the same pin number scheme as the Wiring Pi project

The good news is that the library can be configured to use the Broadcom numbering schemes using:

GpioFactory.setDefaultProvider(new RaspiGpioProvider(RaspiPinNumberingScheme.BROADCOM_PIN_NUMBERING));

This is a little easier to follow and well documented on lots of sites (e.g. https://pinout.xyz/) and will make more sense to other hardware designers or even language users (e.g. Python).

If you do not want to modify your code, then details of the 3B+ pins are to be found here on the libraries site and this is taken from there:

enter image description here

Your Answer

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

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