digitalPinToPort was not declared in this scope

Here is a dummy example:

#include "Particle.h"

void setup() {

void loop() {


This says digitalPinToPort was not declared in this scope.

What are you trying to do with that line? There is no function called digitalPinToPort on Particle.

Hi @ktalebian

As @Ric said, this does not exist on Particle and with good reason. There are not really ports on the ARM processors like the AVR processors have. In other the works, the return value of this would not be useful for anything.

Are you having trouble porting code from an Arduino project?

Actually with v0.6.1-rc.2 this function was introduced for portability of Arduino libraries, but its usefulness is somewhat obscure.

Although I have to somewhat contradict (or better put in perspecitve) what @bko said about the non-existance of ports on the STM32F ARM processors, there are ports, but it’s true that there is no full-byte access to a set of GPIO pins on the Particle devices, since all the exposed pins are scattered over several 16bit ports with no set of consecutive 8 bits.

From now on you will be able to use digitalPinToPort(), but the usefulness of that function is limited and you won’t be able to achieve the same things with its result you could do on an Arduino.

Here is the definition that can be found in spark_wiring_arduino.h

# ifndef digitalPinToPort
# define digitalPinToPort(P)        ( HAL_Pin_Map()[P].gpio_peripheral )
# endif

I actually want to use Nulsom Rainbow 8x8 Matrix and power it using Photon. I downloaded the Arduino library for it, and that’s where those errors come from. Unless Photon does not support this module.

These are NeoPixel compatible LEDs and as such the Photon will support this module but you might need to adapt the firmware accordingly.
And as said, if you set 0.6.1-rc.2 as target version at least your errors should disappear, but that library is heavily hardware dependent, so you’d be better off with the already available NeoPixel library.