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.begin(9600);
Serial.println("Device is ready");
Serial.begin(9600); // The IDE settings for Serial Monitor/Plotter (preferred) must match this speed
Servo1.attach(servoPin);
// 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++)
Serial.write(message[i]);
{
Servo1.write(90);
}
{
Serial.println();
}
}
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.
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