Pi Pico - Arduino IDE, Pin mapping for GPIO in IDE

Hello.

Arduino IDE with Raspberry Pi Pico board.
Using the "Arduino MBed OS RP2040 board" from Board Manager, for the Pi Pico.

I am just trying to find out what the IDE names are for the GPIO on the board, as I cannot find the information anywhere so far.
Serial1 seems to be the term used for the UART on pins 1 and 2 (top left), but I just cant find a listing of what the GPIO names are, like D0, D1, D2, etc

Does anyone know where a listing is found?
I have looked in the pins_arduino.h file and that only seems to reveal the Analog pins, but I just am unsure how to map the GPIO names on the board itself with what gets used in the IDE.

Pin1 is the UART0 TX, which is used with Serial1 it seems, and is labelled GP0. Using GP0 in the IDE however does not seem to reference the GPIO.

Pin4 is GP4, likewise GP4 doesnt seem to reference to the GPIO. How are these mapped?

Thanks

Pins GP0 through GP29 are mapped to Arduino "pins" 0 through 29.
It looks like you can also use "p0" through "p29"...

Arduino Analog pins 0 through 3 are mapped to pins GP26 through GP29.
.../packages/arduino/hardware/mbed_rp2040/2.2.0/variants/RASPBERRY_PI_PICO/variant.cpp

.../packages/arduino/hardware/mbed_rp2040/2.2.0/variants/RASPBERRY_PI_PICO/pins_arduino.h

.../packages/arduino/hardware/mbed_rp2040/2.2.0/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/PinNames.h

Well first off it is not used with Serial1 but with Serial0 as the label says.

Otherwise yes:- the 1 in the grey box is the physical pin number and as such is something you never refer to in code. Perhaps the only use is in wiring diagrams, but again is rarely used in the Arduino world ether mainly because different versions of the Arduino have different physical forms. For example the Uno has no simple physical scheme numbering you can follow. Also where as you can have a pin 0 in software, you can't have a pin 0 as a physical pin.

The Green boxes containing the GP0 numbers are what you should use in your code and are the same as Arduino Pin numbers.

Other boxes are alternative uses for the pin number. So you will see you can have serial communication coming from pins 0 & 1 or 16 & 17 or 16 & 17. Note how pins 0 & 1 are a stronger shade of the colours on the other pins, this indicates that these are the default pins. Using the faded colour alternative pins means to need to specify the pins you want to use.

The same goes for the two I2C buses, pins 4 & 5 are the default pins for I2C bus 0, with alternate pins meaning you have to specify them. Note here how there are no default pins for I2C bus 1, if you use that bus you have to specify them.

Thanks @Grumpy_Mike, but 'Serial1' is what appears to make Pin1 and Pin2 operate as a Serial UART. 'Serial' seems to pipe to the USB port. Yes I realise it states UART0 on the pin diagram, but that is what I tried first and it doesn't match in reality.
I already have a working demo here running with Serial1, as Serial did not work.

Sorry I mistyped in my original post, RE say Pin 4 is GP4. That was suppose to say GP2. Yes, very aware of physical vs software differences here. I just was not sure how to pinpoint the pin I want to operate as I could not find a reference anywhere.

When I was playing around yesterday, doing setting say GP4 to output, and then setting it high and low, did not do anything. It compiled fine however. Which is why I was asking the question of what term I need to use. I will just point to '4' rather than GP4 in the digitalwrite statement now and see if that works, as it should as you have indicated.

Thanks @westfw I think this is what you are referring to also, as well as p0 through p29.
Thanks also for this reference:
.../packages/arduino/hardware/mbed_rp2040/2.2.0/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TARGET_RASPBERRY_PI_PICO/PinNames.h

I had not found that. That is quite deep in the bowels of the folder structure! the pins_arduino.h is my normal go-to when I am not sure, but it didn't help me in this case.

I will give this a go now, much appreciated.

It's not easy to find. I used ID database utilities which is pretty wonderful (essentially, a command-line tool that implements the "find references" and "find implementation" features of the more advanced IDEs.)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.