Whenever I try to upload this code it says it can't compile for an Arduino Nano

I am writing cod e to trigger a servo via RF transmitter and receiver but I keep om getting the error Error compiling for board Arduino Nano
Here is the code hope someone can help

#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
#include <Servo.h> 
int servoPin = 9;                               // When D0 from the Sound Sensor (connnected to pin 7 on the
Servo Servo1;    
void setup()
  Serial.println("Device is ready");
    Serial.begin(9600);               // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  vw_rx_start(); // Start the receiver

void loop()

  if (vw_get_message(message, &messageLength)) // Non-blocking

    Serial.print("Received: ");
    for (int i = 0; i < messageLength; i++)


You are getting more than simply "error compiling"
When an error does occur in the IDE, there is a handy-dandy "Copy error messages" button near the bottom right, click it and paste it here in the forum for people to help you.

Arduino: 1.8.12 (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

libraries\Servo\avr\Servo.cpp.o (symbol from plugin): In function `ServoCount':

(.text+0x0): multiple definition of `__vector_11'

libraries\VirtualWire\VirtualWire.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Servo.h"
Used: C:\Users\natan rosman\Documents\Arduino\libraries\Servo
Not used: C:\Program Files (x86)\Arduino\libraries\Servo
exit status 1
Error compiling for board Arduino Nano.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

That is the Timer1 interrupt that both the Servo library VirtualWire library want to use. Can't use both. Luckily, there is a ServoTimer2 library you can use to move your servos onto Timer2

how do I do that?
what do I have to change

I am not google. Google it

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