Servo/VirtualWare Conflict

Hi,

I'm working on a project which requires I connect both an RF receiver and a Servo motor to an Arduino Uno. However, when I compile the code, I get an error that both libraries are trying to define "__vector_11". I've determined that they are both trying to use the 16-bit timer on the Uno board. Is there any way for me to control the Servo with one of the 8 bit timers? Are there any other solutions to this problem?

Here's the code/error:

#include <VirtualWire.h>
#include <Servo.h>

Servo myServo;

void setup()
{
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_set_rx_pin(12);
    vw_setup(4000);  // Bits per sec
    pinMode(13, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(7, OUTPUT);
    myServo.attach(9);
    
    vw_rx_start();       // Start the receiver PLL running
}
    void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      if(buf[0]=='1'){
   digitalWrite(13,1);
   digitalWrite(8,HIGH);
   digitalWrite(7,LOW);
   myServo.write(90);
   }  
      
      if(buf[0]=='0'){
   digitalWrite(13,0);
   digitalWrite(8,LOW);
   digitalWrite(7,HIGH);
   myServo.write(0);
   }

}
}

Error:

Servo/Servo.cpp.o: In function __vector_11': /Users/AMeehan17/Downloads/Arduino 2.app/Contents/Resources/Java/libraries/Servo/Servo.cpp:103: multiple definition of __vector_11'
VirtualWire/VirtualWire.cpp.o:/Users/AMeehan17/Documents/Arduino/libraries/VirtualWire/VirtualWire.cpp:588: first defined here

Try using the library ServoTimer2 - it may solve the problem.

...R

I've tried the library and I've edited the source code so that the .cpp file is #include <arduino.h>

I'm still getting a bunch of errors about "WConstants.h" though it's no longer in the C++ code. I've removed the library from the arduino compiling program and readded it with the edited source code. Here are the errors I'm getting when I do that:

/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:6:26: error: WConstants.h: No such file or directory
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp: In function 'void __vector_9()':
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:36: error: 'LOW' was not declared in this scope
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:36: error: 'digitalWrite' was not declared in this scope
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:43: error: 'HIGH' was not declared in this scope
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:43: error: 'digitalWrite' was not declared in this scope
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp: In member function 'uint8_t ServoTimer2::attach(int)':
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:66: error: 'OUTPUT' was not declared in this scope
/Users/AMeehan17/Documents/Arduino/libraries/ServoTimer2/ServoTimer2.cpp:66: error: 'pinMode' was not declared in this scope

Do you need to make the same change in the .h file?

Sorry I don't think I have the library on my PC at the moment - but it did work for me and I can't remember what, if any, changes I had to make.

...R