Error Compiling for board Arduino Uno

I am trying to use both the Servo and RadioHead libraries to remotely control a Servo with a joystick. Initially my code was working, but at some point I must have changed something and now it is all broken. I have tried unistalling and re-installing the IDE as well as the RH library. I have tried plugging it into different ports on my computer, different computers, different Arduino, nothing seems to make a difference.

I have literally tried uploading a code that is simply #include <RH_ASK.h> and #inlude <Servo.h> along with blank setup and loop functions and I am having the same problem. When I try to include them seperately it works, but when I try to put them in the same code I keep getting the same error:

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

libraries/RadioHead/RH_ASK.cpp.o (symbol from plugin): In function RH_ASK::maxMessageLength()': (.text+0x0): multiple definition of __vector_11'
libraries/Servo/avr/Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.

Any help would be greatly appreciated. I am trying to teach my students the fun of Arduino in a club, but I must admit this has stumped me for quite a while.

sketch_mar23b.ino (170 Bytes)

This looks like conflict in defines in libraries. One variable is defined multiple times.

You can modify one of these libraries, I'd recommend RH lib and find and replace "__vector_11" with something else, for example "__rh_vector_11".

Now try compiling again, and see if it fixed the error.

The error message is rather cryptic, the problem is that the Servo and RadioHead libraries both use hardware timer1. If you look at the RH_ASK.cpp file in the RadioHead library, you will find the following (I added the line numbers to the left of each line):

 24 
 25 // RH_ASK on Arduino uses Timer 1 to generate interrupts 8 times per bit interval
 26 // Define RH_ASK_ARDUINO_USE_TIMER2 if you want to use Timer 2 instead of Timer 1 on Arduino
 27 // You may need this to work around other librraies that insist on using timer 1
 28 // Should be moved to header file
 29 //#define RH_ASK_ARDUINO_USE_TIMER2
 30

Uncomment the #define on line 29 and the error should go away.

david_2018, this worked thank you so much!

From the how to use this forum sticky post:
If you consider the issue solved, please edit your original post (the first one in the thread) and add "[solved]" to the subject line. That helps people know the issue is resolved. Also please post the solution, whether you worked it out yourself, or if someone else helped you. A note that "this was solved by doing X" is very helpful to other people with the same problem. Thanks!

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