I am having this problem when trying to compile my sketch. I am using RF frequency modules to send data between devices and a servo motor to control the tilt of a ramp. I understand that both libraries use TIMER 1 but I am unsure how to change one of them to use TIMER 2 thanks.
Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':
(.text+0x0): multiple definition of `__vector_11'
libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
Board at COM4 is not available
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
3 Answers 3
You can force the RadioHead library to use Timer 2 instead. This can be done by enabling the define RH_ASK_ARDUINO_USE_TIMER2 near the top of RH_ASK.cpp.
More details about how to do this may be found in the RadioHead library documentation. Please see https://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html.
Cheers!
Mikael Patel pretty much gave the answer but I want to be more precise with it.
In your Arduino libraries folder (C:\Users[USER_NAME]\Documents\Arduino\libraries\RadioHead) there is a file called "RH_ASK.cpp" where you have to insert this line:
#define RH_ASK_ARDUINO_USE_TIMER2
You can open the cpp file with Notepad. I added the line between "include <RHCRC.h>" and "#ifndef SAMD51" and it worked for me.
I know it's an old post, but the previous answer didn't help me yesterday, so I hope this help someone in the future as well.
You can also use the ServoTimer2 library to move the servos to timer 2 if you'd prefer that.