When using the Raspberry Pi's GPIO header, there are a number of different ways used to describe the pin being used, these are:

  • The Broadcom numbers - the numbers used by the processor
  • The Raspberry Pi numbers - the numbers used by the foundation
  • The physical numbers - the physical pin on the board


It can get confusing knowing which numbers to use, for this reason Pi# contains enumerated types for all three numbering systems. Each method is overloaded so that it may be called using any of the numbering systems. Internally, the numbers are converted to the Broadcom numbers, so you may choose to use whatever system you prefer and can even mix and match if you like (although that's probably a good way to get confused!).

For example, the below code is valid and all refers to the same output pin. It will cause the LED connected to pin 22(physical)/ 25(Bradcom)/ 6(Raspberry) - or the LED on the far right when using the simulator - to blink:

while (true)
{
     LibGpio.Gpio.OutputValue(BroadcomPinNumber.TwentyFive, true);      Thread.Sleep(200);      LibGpio.Gpio.OutputValue(PhysicalPinNumber.TwentyTwo, true);      Thread.Sleep(200);      LibGpio.Gpio.OutputValue(RaspberryPinNumber.Six, true);      Thread.Sleep(200); }

(For brevity the code to configure the pins for output is excluded)

Last edited Jun 18, 2012 at 1:14 PM by CliveB58, version 9