Multiple Libraries for Servo.h Found

#include <Servo.h>
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK radio ;
Servo servo_pan ;
Servo servo_tilt ;

  uint8_t xaxis = 0 ;
  uint8_t yaxis = 0 ;
  uint8_t servo_pan_value = 0 ;
  uint8_t servo_tilt_value = 0 ;
  int mapped_x = 0 ;
  int mapped_y = 0 ;
  int mapped_pan = 0 ;
  int mapped_tilt = 0 ;

int En1 = 11 ;
int in1 = 7 ;
int in2 = 8 ;
int in3 = 9 ;
int in4 = 10 ;
int En2 = 12 ;

       void setup() {

// put your setup code here, to run once:

  servo_pan.attach(5) ;
  servo_tilt.attach(6) ;
           radio.init() ;
       pinMode( En1, OUTPUT ) ;
       pinMode( in1, OUTPUT ) ;
       pinMode( in2, OUTPUT ) ;
       pinMode( in3, OUTPUT ) ;
       pinMode( in4, OUTPUT ) ;
       pinMode( En2, OUTPUT ) ;
 }

      void loop() {

// put your main code here, to run repeatedly:

  uint8_t data[4] ;
  uint8_t datalen = 4 ;
  
 if( radio.recv(data, &datalen )) {
     

      if( ( xaxis > 450 ) && (xaxis < 450 ) && ( yaxis > 450 ) && ( yaxis < 550 ) ) {
          digitalWrite( in1, LOW ) ;
          digitalWrite( in2, LOW ) ;
          digitalWrite( in3, LOW ) ;
      }

      if( yaxis > 550 ) {
           digitalWrite( in1, HIGH ) ;
           digitalWrite( in2, LOW ) ;
           digitalWrite( in3, LOW ) ;
           digitalWrite( in4, HIGH ) ;
      }

      if( xaxis < 450 ) {
          digitalWrite( in1, HIGH ) ;
          digitalWrite( in2, LOW ) ;
          digitalWrite( in3, HIGH ) ;
          digitalWrite( in4, LOW ) ;
      }

      if( xaxis > 550 ) {
           digitalWrite( in1, LOW ) ;
           digitalWrite( in2, HIGH ) ;
           digitalWrite( in3, LOW ) ;
           digitalWrite( in4, HIGH ) ;
      }

      if( yaxis < 450 ) {
           digitalWrite( in1, LOW ) ;
           digitalWrite( in2, HIGH ) ;
           digitalWrite( in3, HIGH ) ;
           digitalWrite( in4, LOW ) ;
      }

            xaxis = data[3] ;
            yaxis = data[2] ;
            servo_pan_value = data[1] ;
            servo_tilt_value = data[0] ;
            
      mapped_x = map( xaxis , 0 , 1023 , 0 , 255 ) ;
      mapped_y = map( yaxis , 0 , 1023 , 0 , 255 ) ;
      mapped_pan = map( servo_pan_value , 0 , 1023 , 0 , 255 ) ;
      mapped_tilt = map( servo_tilt_value , 0 , 1023 , 0 , 255 ) ;
          
       analogWrite( En1, 0 + mapped_x ) ;
       analogWrite( En2, 0 + mapped_y ) ;
       servo_pan.write( mapped_pan ) ;
       servo_tilt.write( mapped_tilt ) ;
}
      }

Error:
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 Uno.

Can you please edit your opening post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

Your problem is that both the RadioHead and the Servo library want to use the same interrupt; your problem is not that multiple libraries were found :wink:

The use of the ServoTimer2 library will probably solve the problem.

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