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.
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.
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!