0

Is there any option in pigpio library that sets pinout mode as BCM or BOARD ? I decided that in pigpio default is BCM but in RPi.GPIO there is an option to change that like

GPIO.setmode(GPIO.BOARD)

or

GPIO.setmode(GPIO.BCM)

so i wanted to know if it is available in pigpio.

2

pigpio only accepts BCM numbering.

Of course you could always write a Python function to convert from BOARD numbering to BCM. For the 40 pin Pis the following would work.

BOARD2BCM=[
   -1, -1,  2, -1,  3, -1,  4, 14,
   -1, 15, 17, 18, 27, -1, 22, 23,
   -1, 24, 10, -1,  9, 25, 11,  8,
   -1,  7,  0,  1,  5, -1,  6, 12,
   13, -1, 19, 16, 26, 20, -1, 21]

def Board_to_BCM(pin):
   if pin < 1 or pin > 40:
      return -1
   else:
      return BOARD2BCM[pin-1]

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.