Error message. servo.h , RH_ASK.h

Hi i am new here , looking forward to help and be helped <3 , still new in the filed of arduino and programming in general
so i am using RH_ASK.h (RadioHead library) whenever i use servo.h with it , its corrupted and give me an error of indicating that there is a variable is being defined again (maybe?).
this is the error

Arduino: 1.8.5 (Windows 8.1), TD: 1.42, Board: "Arduino/Genuino 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.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

i am trying to make two servos work on a joystick module with rf 433hz module.
also i tried just to read the transmitted data and it wasnt alright , the transmission circuit mapping works fine from 0 to 180 but in the receiving circuit it reads from 0 to 31 for x-axis and y-axis is 0 all the time

The Code:

// transmitting
#include<SPI.h>
#include<RH_ASK.h>

RH_ASK d;

void setup() {
Serial.begin(9600);
d.init();
}

void loop() {
  uint8_t a[1];
int x = analogRead(A0);
int y = analogRead(A1);
int x0 = map(x , 0 , 1023 , 0 , 180);
int y0 = map(y , 0 , 1023 , 0 , 180);
  Serial.println(x0);
  Serial.println(y0);
a[0] = (uint8_t) x0;
a[1] = (uint8_t) y0;
d.send( a , 1);
d.waitPacketSent();
}


// recieving
#include<Servo.h>
#include<SPI.h>
#include<RH_ASK.h>

RH_ASK d;


void setup() {
 d.init();
 Serial.begin(9600);
}

void loop() {
 uint8_t b[1];
 uint8_t bsize = sizeof(b);
 if(d.recv(b , &bsize))
 {

int x0 = map(b[0] , 0 , 1023 , 0 , 180);
int y0 = map(b[1] , 0 , 1023 , 0 , 180);

  Serial.println(x0);
  Serial.println(y0);
 }
}

sorry i dont know how to put the code in a neat way xD , nothing really fancy i just wanted to test them out so i can use them with my project
Thank You Very Much for taking your time reading my post <3.

sorry i dont know how to put the code in a neat way xD

well if you had read the links at the top of the forum you would....
Read this before posting a programming question ...
How to use this forum - please read.

Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

-————

regarding your question, this error message code: multiple definition of `__vector_11'[/code] tells you that your libraries are using the same interrupt code and thus conflicting... (Both the Servo library and the RadioHead library use Timer 1)

There is a way to modify the RadioHead library to use Timer2 instead

ok thank you <3.
so if i just uncomment the line with the definition of Timer2
is it good to go? or do i need to modify something else in the code?
i am just worry that it will corrupt the library itself.

Or you could leave RH_ASK.h alone and use ServoTimer2.h instead of Servo.h though you might need to change your servo code, if you've written any, to use write(microseconds) instead of write(angle).

Steve

krom:
ok thank you <3.
so if i just uncomment the line with the definition of Timer2
is it good to go? or do i need to modify something else in the code?
i am just worry that it will corrupt the library itself.

yes uncommenting line 26 is all you need - give it a try, it won't break anything (well, probably :slight_smile: )

slipstick:
Or you could leave RH_ASK.h alone and use ServoTimer2.h instead of Servo.h though you might need to change your servo code, if you've written any, to use write(microseconds) instead of write(angle).

Steve

Thank you that was helpful !! , i could use that later on.<3

J-M-L:
yes uncommenting line 26 is all you need - give it a try, it won't break anything (well, probably :slight_smile: )

Thank you it worked.
just so i know that i am not doing it wrong , i edited it like that
documents/arduino/libraries/RadioHead
then modified the cpp file RH_ASK
uncommented the line 26
is that the normal approach or there is a better way to do it?.

one more question and sorry for being kinda annoying and taking your time guys , in the transmission circuit the mapping work just fine from 0 to 180 both x and y but in the receiving circuit x is from 0 to 31 and y is 0 always any idea why?
my thoughts maybe because the other arduino is a clone? it has flashing red leds
maybe i need to strength the signal with antenna? although both the transmitter and receiver are very close to each other.
Thank You <3.

uint8_t a[1];

a[1] = (uint8_t) y0;

You are declaring a 1 element array, and then trying to store something in the second element of that array. You need a 2 element array to have byte 0 and byte 1.

Your sketch is also corrupting whatever variable is after a in memory, which will cause undefined behavior. You do the same thing on the receiver.

Array indexes start from 0, but when you declare the array, the number of elements you pass is the number of elements - it starts from 1, not 0 (the maximum index on an array is length-1, not length).

Nothing to do with whether the receiver is a clone - if you can upload to the clone, it's not completely DOA, and your project doesn't involve uploading special f/w to the 16u2 (which most clones don't have), clones are drop-in replacements.

krom:
Thank you it worked.
just so i know that i am not doing it wrong , i edited it like that
documents/arduino/libraries/RadioHead
then modified the cpp file RH_ASK
uncommented the line 26
is that the normal approach or there is a better way to do it?.

Yes this is the usual way.
Modifying it there means all your new projects will also use that library and thus timer2. The other way to do it without impacting the original would,be to have a local copy in your sketch repository and use “” instead of <> for the includes ( using "” prioritizes headers in the current working directory over system headers. <> usually is used for system headers) but might be tricky with complex hierarchy of files