5

I'm a GPIO newbie experimenting with getting my Raspberry Pi to blink an LED with C using the wiringPi library. The example code at http://wiringpi.com/examples/blink/ (blink.c) compiles perfectly and runs as advertised.

Here's my question: the documentation at http://wiringpi.com/pins/ states that "wiringPi supports its own pin numbering scheme as well as the BCM_GPIO pin numbering scheme", but I can't find any instructions on how to use the BCM_GPIO numbers. I realize that there may be good reasons to prefer the wiringPi numbering scheme over BCM_GPIO, but for the sake of knowing how it's done, how would I change blink.c to use the BCM_GPIO numbering scheme?

5

To set a pin numbering scheme you use one of four Setup functions:

  • int wiringPiSetup (void);
  • int wiringPiSetupGpio (void);
  • int wiringPiSetupPhys (void);
  • int wiringPiSetupSys (void);

To use BCM GPIO numbering you would replace you would use wiringPiSetupGpio(void); and modify the pin numbers in your code appropriately.

  • Here is also an especially good diagram showing the pin-outs ... pighixxx.com/test/2015/06/raspberry-pi-v2-mod-b-pinout – Kolban Dec 27 '15 at 6:13
  • @Kolban The diagram would be more helpful if it included all of the pin numbering schemes supported by wiringpi. While the linked diagram is pretty, form should follow function in this case. – Steve Robillard Dec 27 '15 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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