Hi everyone I am creating a project with an ultrasonic sensor and a servo motor, only in my code putting both newTone.h and servo.h as libraries they conflict so they cannot start the code. I need help what can I do? it is quite urgent
This is the code:
#include <NewPing.h>
#include <NewTone.h>
#include <Servo.h>
#define PIN_TRIG 2
#define PIN_ECHO 3
#define PIN_BUZZ 9
#define MAX_DIST 10
NewPing detector(PIN_TRIG, PIN_ECHO, MAX_DIST);
int mal;
Servo mio;
void setup()
{
Serial.begin(9600);
{
mio.attach(8);
}
}
void loop()
{
//delay(500);
unsigned int uS = detector.ping();
Serial.print("Dista: ");
int cm = detector.convert_cm(uS);
Serial.print(cm);
Serial.println(" cm");
if(cm > 0)
{
int durationSound = 1000/8;
NewTone(PIN_BUZZ,200,durataSuono);
int pause = durationSound * 1.30;
delay(pause);
noNewTone(PIN_BUZZ);
for (mal = 0; mal < 180; mal++)
{
Serial.println(mal);
mio.write(mal);
delay(13);
}
for (mal = 179; mal > -1; mal--)
{
Serial.println(mal);
io.write(mal);
delay(13);
}
}
}
The error code is this:
libraries\NewTone\NewTone.cpp.o (symbol from plugin): In function NewTone(unsigned char, unsigned long, unsigned long)': (.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 the Arduino Uno board.
I apologize if I can not put the code well but I hope it is now more understandable.