# digitalPinToPinName compile error on Nano 33 BLE

**URL:** <https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966>\
**Category:** Nano 33 BLE\
**Created:** [June 15, 2021, 3:58pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966 "2021-06-15T15:58:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daanstevenson](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/daanstevenson/32/490014_2.png) [@daanstevenson](https://forum.arduino.cc/u/daanstevenson)\
**Post date:** [June 15, 2021, 3:58pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966/1 "2021-06-15T15:58:20Z")

</div>

Hi,

Just getting started with the Nano 33 BLE, and am seeing a strange compile error when I use digitalPinToPinName.  
When I hard code using P1\_12, it compiles just fine.  
I have tried the mbed 2.1.0 board files as well as the deprecated version.  
In the IDE 2.0 the digitalPinToPinName definition links to pinDefinitions.h and variant.cpp just fine.  
I don't have the boards in yet, but that shouldn't affect the compile, right?  
Any thoughts?

Code:

```arduino
/*
  Code to test PWM functionality
*/

#include "mbed.h"

#define MOTOR_PIN P1_12
#define MOTOR_PIN_NUM 3

//mbed::PwmOut motorPWM( MOTOR_PIN );
mbed::PwmOut motorPWM( digitalPinToPinName ( MOTOR_PIN_NUM ) );

void setup() {
  // put your setup code here, to run once:

  motorPWM.period(0.000125); // period = 125 us, freq = 8kHz
  motorPWM.write(0.0);

}

void loop() {
  // put your main code here, to run repeatedly:

  for (float dutyCycle = 0; dutyCycle < 50; dutyCycle += 5) {
    motorPWM.write( dutyCycle / 100.0 ); // duty cycle steps up 5% per second
    delay( 1000 );
  }
}

```

Error:

> sketch\test\_pwm.ino.cpp.o: In function `__static_initialization_and_destruction_0': C:\...\test_pwm/test_pwm.ino:11: undefined reference to `digitalPinToPinName(unsigned char)'  
> collect2.exe: error: ld returned 1 exit status  
> exit status 1  
> Error compiling for board Arduino Nano 33 BLE.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [June 15, 2021, 4:08pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966/2 "2021-06-15T16:08:15Z")

</div>

Hi @daanstevenson. You can learn about the reason for this change here:  
[https://github.com/arduino/ArduinoCore-mbed/issues/244#issuecomment-855817812](https://github.com/arduino/ArduinoCore-mbed/issues/244#issuecomment-855817812)

So you can fix the error by adding this line to your sketch:

```cpp
#include <pinDefinitions.h>

```

---

<div class="post-metadata">

**Author:** ![Klaus\_K](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/klaus_k/32/626942_2.png) [@Klaus\_K](https://forum.arduino.cc/u/Klaus_K)\
**Post date:** [June 15, 2021, 4:08pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966/3 "2021-06-15T16:08:32Z")

</div>

The Arduino team decided to make this function private. You have to include a header file.

```cpp
#include "pinDefinitions.h"

```

If you want to know a bit more about it here is the GitHub link with an issue I created a little while ago.

[https://github.com/arduino/ArduinoCore-mbed/issues/244](https://github.com/arduino/ArduinoCore-mbed/issues/244)

---

<div class="post-metadata">

**Author:** ![daanstevenson](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/daanstevenson/32/490014_2.png) [@daanstevenson](https://forum.arduino.cc/u/daanstevenson)\
**Post date:** [June 15, 2021, 5:13pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966/4 "2021-06-15T17:13:12Z")

</div>

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 13, 2021, 5:13pm UTC](https://forum.arduino.cc/t/digitalpintopinname-compile-error-on-nano-33-ble/874966/5 "2021-10-13T17:13:52Z")

</div>

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