433 MHZ Radio and servo issues

Hello everyone,

I am trying to make a circuit for a radio controlled boat using 433 MHZ modules. The boat is a simple foam hull with the electronics on top. Basically, the transmiter has 3 buttons: Forward, left and right. The propulsion is a common 3V dc motor, and the steering uses a regular sg90 (the small blue box) servo.

Each time a button is pressed on the transmiter (short: TX) it sends a single character (1, 2 and 3) to the reciever (RX).

As for the motor, I use the l239d driver chip (just the IC) with a 3v external power supply. Depending on the character recieved, it does a different function (forward, left or right).

The code without the servo works fine. However, when I include the servo library, it gives me the "exit status 1" error, with no more info. Full error:

C:\Users\Usuario\AppData\Local\Temp\arduino\sketches\A93E5929FF3DB4F7B36C25D314874E47\libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin): In function RH_ASK::maxMessageLength()': (.text+0x0): multiple definition of __vector_11'
C:\Users\Usuario\AppData\Local\Temp\arduino\sketches\A93E5929FF3DB4F7B36C25D314874E47\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

Compilation error: exit status 1

Here i post the full code, with explanations:

 /* Hello everyone, please keep in mind
that I am better at hardware than software,
if you see any issues, or any way to improve
the code I am all ears, thanks.

Basically, when one character is recieved, the if statements tell the driver what to do.
The 500 ms delay is there so that for half a second the motor starts running, 
and when the time pases it goes back to zero, unless it recieves a new input. 
Then the delay time of the motor stopped is so small that it inmediately starts
the motor again, so that it is more or less "sensitive" to the inputs*/   

#define in1 6 //define inputs for the l239d driver  
#define in2 5

#include <Servo.h>   //servo library
#include <RH_ASK.h>		// mighty Radio Head
#include <SPI.h> 		// SPI library for the radio

RH_ASK rf_driver;		// for the ASK library and the radio

Servo rudder; //create the servo object for the servo that moves the rudder

void setup() {
  pinMode(in1, OUTPUT); //for the l239d chip
  pinMode(in2, OUTPUT);
  rudder.attach(2); //servo pin is 2
  rudder.write(90); //servo to middle position
  rf_driver.init(); 
}

void loop() {
  uint8_t buf[1];		//space for 1 character message 
  uint8_t buflen = sizeof(buf);	// define buffer length
  if (rf_driver.recv(buf, &buflen)){ //if mesage recieved

    if ((char)buf[0] == '1'){ //if mesage  is character "2"

      digitalWrite(in1, HIGH); //move the motor forward
      digitalWrite(in2, LOW);
      delay(500);
      digitalWrite(in1, LOW);
      delay(1);
    }

    else if((char)buf[0]== '2'){ //if mesage is character "2"
      digitalWrite(in1, HIGH);  //move the motor the other way AND move the servo left
      digitalWrite(in2, LOW);
      rudder.write(130); //move servo left
      delay(500);  //I don't know if this method is efficient but it is what I know
      digitalWrite(in1, LOW); //stop motor
      rudder.write(90); //servo to middle
      delay(1);
    }
    else if((char)buf[0]== '3'){ //if the mesage is character "3"

      digitalWrite(in1, HIGH); //move the motor forward
      digitalWrite(in2, LOW);
      rudder.write(50); //move servo right
      delay(500);
      digitalWrite(in1, LOW); //stop motor
      rudder.write(90); //servo to middle
      delay(1);
    }
  }
}
//The end

If anyone knows how to fix it, I would be very, very gratefull.

Arduinomaker1897

Do a Google search for " multiple definition of `__vector_11" and you will find that there is a conflict between the Servo and RH_ASK libraries over the use of a timer. Try a different servo library. I see the ServoTimer2 library suggested in similar circumstances.

Does the timer issue occur without a servo library? If not, this simulation show how to drive a servo without a library, which is no more technical than using a library if you put your rudder.write(x) in its own function. (the sketch is cluttered with my comments - easily removed)

It works. Now I can compile the code without any issues, and it does what it's supposed to do.

Thank you very much!

Althought I have solved the issue, tnak you very much for the post. It is an interesting way to move a servo.

Thanks!

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