Hi all,
I’m writing an arduino program (on Arduino Uno) wich includes 2 libraries: VirtualWire and Servo.
//receiver
#include <Servo.h>
#include <VirtualWire.h>
Servo servo;
int posit = 90;
int change = 5;
void setup() {
Serial.begin(9600);
vw_set_ptt_inverted(true);
vw_set_rx_pin(12);
vw_setup(4000);
vw_rx_start();
servo.attach(7);
}
void loop() {
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if(vw_get_message(buf, &buflen)) {
Serial.println("message");
if(buf[0]=='L') {
Serial.println("left");
posit = posit - change;
}else if(buf[0]=='R') {
Serial.println("right");
posit = posit + change;
}else if((buf[0]!='L') || (buf[0]!='R')) {
}
}
if(posit > 180) {
posit = 180;
}else if(posit < 0) {
posit = 0;
}
servo.write(posit);
delay(5);
}
When I want to do the compilation there appears this error:
libraries\VirtualWire\VirtualWire.cpp.o (symbol from plugin): In function `vw_crc':
(.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
Błąd kompilacji dla płytki Arduino/Genuino Uno.
I don’t know what it means and how to repair it. Could someone help me?
There is also a receiver code on Arduino Mega, but I think it’s not necessary for you:
//transimtter
#include <VirtualWire.h>
const char *message = "can smn help me";
#define przycisk_prawy 8
#define przycisk_lewy 9
void setup() {
Serial.begin(9600);
pinMode(przycisk_lewy, INPUT_PULLUP);
pinMode(przycisk_prawy, INPUT_PULLUP);
vw_set_ptt_inverted(true);
vw_set_tx_pin(12);
vw_setup(4000);
}
void loop() {
if(digitalRead(przycisk_lewy) == LOW) {
Serial.println("left");
message="L";
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx();
Serial.println("sent");
}else if(digitalRead(przycisk_prawy) == LOW) {
Serial.println("right");
message="R";
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx();
Serial.println("sent");
}
delay(250);
}