servo.h problem, error: exit status 1, Nano 33 BLE fails to compile

Hello, I am trying to write a sketch to make a servo move 90 degrees using an Arduino Nano 33 BLE. I believe the only library I need for it is the Servo library with the Servo.h header file.
I do not understand the following error. Is it maybe a problem with the header file or the code?

#include <Servo.h>
int Xpin = 1;
Servo Xservo;

void setup() {
  delay(500);
  Xservo.attach(Xpin);
  Xservo.write(90);
}
void loop() {
}

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:7:11: error: ‘DigitalOut’ in namespace ‘mbed’ does not name a type
mbed::DigitalOut *pin;
^~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:8:11: error: ‘Timeout’ in namespace ‘mbed’ does not name a type
mbed::Timeout timeout; // calls a callback once when a timeout expires
^~~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:9:11: error: ‘Ticker’ in namespace ‘mbed’ does not name a type
mbed::Ticker ticker; // calls a callback repeatedly with a timeout
^~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In constructor ‘ServoImpl::ServoImpl(PinName)’:
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:7: error: ‘pin’ was not declared in this scope
pin = new mbed::DigitalOut(_pin);
^~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:7: note: suggested alternative: ‘min’
pin = new mbed::DigitalOut(_pin);
^~~
min
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:17: error: expected type-specifier
pin = new mbed::DigitalOut(_pin);
^~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In destructor ‘ServoImpl::~ServoImpl()’:
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:17:9: error: ‘ticker’ was not declared in this scope
ticker.detach();
^~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:17:9: note: suggested alternative: ‘time’
ticker.detach();
^~~~~~
time
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:18:9: error: ‘timeout’ was not declared in this scope
timeout.detach();
^~~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:18:9: note: suggested alternative: ‘timer_t’
timeout.detach();
^~~~~~~
timer_t
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:19:16: error: ‘pin’ was not declared in this scope
delete pin;
^~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:19:16: note: suggested alternative: ‘min’
delete pin;
^~~
min
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function ‘void ServoImpl::start(uint32_t)’:
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:24:7: error: ‘ticker’ was not declared in this scope
ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);
^~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:24:7: note: suggested alternative: ‘time’
ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);
^~~~~~
time
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function ‘void ServoImpl::call()’:
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:28:9: error: ‘timeout’ was not declared in this scope
timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);
^~~~~~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:28:9: note: suggested alternative: ‘timer_t’
timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);
^~~~~~~
timer_t
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function ‘void ServoImpl::toggle()’:
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:33:8: error: ‘pin’ was not declared in this scope
*pin = !*pin;
^~~
C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:33:8: note: suggested alternative: ‘min’
*pin = !*pin;
^~~
min
Using library Servo at version 1.1.6 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
exit status 1
Error compiling for board Arduino Nano 33 BLE.

I compiled the posted sketch for board
ardunio Uno
Arduino Nano
Arduino BT

they all compiled with Arduino IDE 1.8.12 without any errors

What Arduino IDE release do you use?

What board do you have selected in the board manager?
Where is the servo.h file located on your harddisc?

best regards Stefan
any newbee can apply the most professional habit from the first line of code they write on their own:
add only ONE thing at a time. Test/debug that ONE thing until that ONE thing works reliable - repeat.
The sad thing is: only the REAL professionals write code this way.

Hey Stefan, thanks for the reply.

I am using Arduino 1.8.13

I have selected Arduino nRF528x Boards (MBED OS) > Arduino Nano 33 BLE

The Servo.h file is located at C:\Program Files (x86)\Arduino\libraries\Servo\src
It is not located at C:\Users\name\Documents\Arduino\libraries

with thi sboard selected I can confirm the compiler error

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:8:11: error: 'Timeout' in namespace 'mbed' does not name a type

     mbed::Timeout      timeout;  // calls a callback once when a timeout expires

           ^~~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:9:11: error: 'Ticker' in namespace 'mbed' does not name a type

     mbed::Ticker       ticker;   // calls a callback repeatedly with a timeout

           ^~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In constructor 'ServoImpl::ServoImpl(PinName)':

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:7: error: 'pin' was not declared in this scope

       pin = new mbed::DigitalOut(_pin);

       ^~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:7: note: suggested alternative: 'min'

       pin = new mbed::DigitalOut(_pin);

       ^~~

       min

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:13:17: error: expected type-specifier

       pin = new mbed::DigitalOut(_pin);

                 ^~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In destructor 'ServoImpl::~ServoImpl()':

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:17:9: error: 'ticker' was not declared in this scope

         ticker.detach();

         ^~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:17:9: note: suggested alternative: 'time'

         ticker.detach();

         ^~~~~~

         time

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:18:9: error: 'timeout' was not declared in this scope

         timeout.detach();

         ^~~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:18:9: note: suggested alternative: 'timer_t'

         timeout.detach();

         ^~~~~~~

         timer_t

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:19:16: error: 'pin' was not declared in this scope

         delete pin;

                ^~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:19:16: note: suggested alternative: 'min'

         delete pin;

                ^~~

                min

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::start(uint32_t)':

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:24:7: error: 'ticker' was not declared in this scope

       ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);

       ^~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:24:7: note: suggested alternative: 'time'

       ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);

       ^~~~~~

       time

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::call()':

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:28:9: error: 'timeout' was not declared in this scope

         timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);

         ^~~~~~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:28:9: note: suggested alternative: 'timer_t'

         timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);

         ^~~~~~~

         timer_t

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::toggle()':

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:33:8: error: 'pin' was not declared in this scope

       *pin = !*pin;

        ^~~

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:33:8: note: suggested alternative: 'min'

       *pin = !*pin;

        ^~~

        min

In file included from C:\Users\Stefan\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.1.6\variants\ARDUINO_NANO33BLE/pins_arduino.h:3:0,

                 from C:\Users\Stefan\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.1.6\cores\arduino/Arduino.h:86,

                 from C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:3:

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'uint8_t Servo::attach(int, int, int)':

C:\Users\Stefan\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.1.6\cores\arduino/macros.h:28:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

 #define digitalPinToPinName(P)      (P >= PINS_COUNT ? NC : g_APinDescription[P].name)

C:\Program Files (x86)\Arduino\libraries\Servo\src\mbed\Servo.cpp:64:44: note: in expansion of macro 'digitalPinToPinName'

   servos[this->servoIndex] = new ServoImpl(digitalPinToPinName(pin));

                                            ^~~~~~~~~~~~~~~~~~~

Using library Servo at version 1.1.6 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
exit status 1
Error compiling for board Arduino Nano 33 BLE.

So maybe you start a new thread in the Arduino Forum> Using Arduino> Installation & Troubleshooting sub-forum

Please don't start another thread. If you find that a thread is in the wrong section, you can click the "Report to moderator" link at the bottom of any post to request the moderator to move it.

I'm going to take a look at the issue now.

This bug has been fixed, but there hasn't been a release of the Servo library since the time of the fix. So you'll need to install the beta testing version of the library following these instructions:

After that, you should be able to use the Servo library with your Nano 33 BLE.

I am still unable to get the library to work with my Nano 33 BLE Sense. I get the following message:

WARNING: library Servo claims to run on avr, megaavr, sam, samd, nrf52, stm32f4, mbed architecture(s) and may be incompatible with your current board which runs on mbed_nano architecture(s).
C:\Users\Kyescott\AppData\Local\Temp\arduino-sketch-479B7FFA56EBA976BCC15F36D18718DE\libraries\Servo\mbed\Servo.cpp.o: In function Servo::attach(int, int, int)': C:\Users\Kyescott\Documents\Arduino\libraries\Servo\src\mbed/Servo.cpp:65: undefined reference to digitalPinToPinName(unsigned char)’
collect2.exe: error: ld returned 1 exit status

This is using Servo library version 1.1.7 downloaded directly from the library manager within the IDE. Is there a bug related to the digitalPinToPinName() function, or do you have any ideas what could be causing this issue?

Hi @Kyescott. It seems that an incompatibility was introduced in the 2.0.0 release of the Arduino Mbed OS board platform.

You can resolve this by using the previous version. Please try this:

  1. Select Tools > Board > Boards Manager from the Arduino IDE"s menus.
  2. Wait for the update to finish.
  3. Scroll down through the list of available boards platforms until you see “[Deprecated - Please install standalone packages] Arduino Mbed OS Boards”. Click on it.
  4. Click the “Install” button.
  5. Wait for the installation to finish.
  6. Click the “Close” button.
  7. Select Tools > Board > Arduino Mbed OS Boards (nRF52840 / STM32H747 > Arduino Nano 33 BLE from the Arduino IDE’s menus.

Now try compiling your sketch again.

Note that, due to the current unique circumstances where the Arduino Mbed OS Boards platform was split into board -specific variants, you will still have the new “Arduino Mbed OS Nano Boards” platform available under the Tools > Board menu, so you can decide when you want to use the old 1.3.2 version or the new 2.0.0 version of the boards platform at will. If you eventually decide you want to uninstall one of them, you can do that by clicking the “Remove” button in Boards Manager.

Thanks for the unreasonably prompt reply! I can follow your steps 1-6 without problem, but once version 1.3.2 of [DEPRECATED - Please install standalone packages] Arduino Mbed OS Boards is installed, I don’t see the Arduino Mbed OS Boards (nRF52840 / STM32H747 option. I only see the new Arduino MBed OS Nano Boards option and the same issue as before persists upon compiling the sketch.

I take it back! I was using the beta version of the 2.0 IDE, and it doesn’t show there. In the old IDE, however, it does and it compiles correctly given that fix. Thank you.

Hi. Sorry about that. I can also reproduce this bug with Arduino IDE 2.0. I had only tested the instructions above using Arduino IDE 1.8.13 so I didn’t notice this before.

I have submitted a report to the IDE developers about this bug of IDE 2.0 not showing the 1.3.2 version.

Thanks for taking the time to post an update with this information.
Enjoy!
Per

Thanks for that. I was also running into this issue on the 2.0 beta and was wondering what everyone was talking about :slight_smile:

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