error

Here is a program I wrote that I get errors for. Before writing this, I had tow programs, one for the servo, the other for the LED and piezo, and no errors. Once I combined them, it does not work anymore, and it seems it has problems with the libraries:

#include <Servo.h>
#include <toneAC.h>

Servo myServo;
const int sensorPin=A1;
const float TempThreshold=23.5;
int LEDPins=11;
int firstOrSecond=0;

int const VDPin=A0;
int VDVal;
int angle;
int night=0;

void setup()
{
myServo.attach(6);
Serial.begin(9600); //open a serial port
pinMode(6,OUTPUT);
//pinMode(10,OUTPUT);
//pinMode(LEDPins,OUTPUT);
//digitalWrite(10, LOW);
}

void loop()
{
VDVal=analogRead(VDPin);
Serial.print ("Voltage Divider Value: ");
Serial.println(VDVal);

if (VDVal>700)
{myServo.write(0);}
else
{myServo.write(179);

int sensorVal=analogRead(sensorPin);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
float voltage =(sensorVal/1024.0)*5.0;
Serial.print(", Volts: ");
Serial.print(voltage);
float temperature = (voltage -.5)*100;
Serial.print(", degrees C: ");
Serial.print(temperature);

if(temperature < TempThreshold)
{
digitalWrite(11,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
firstOrSecond=0;
Serial.println(", No Sound ");

} else
{
if(firstOrSecond==0){
int myCounter=0;
Serial.println(" Alarm was tripped");
do
{
analogWrite(11,20);
toneAC(250,1);
delay(500);
toneAC(1500,1);
delay(500);
myCounter = myCounter + 1;}
while(myCounter<15);
firstOrSecond=firstOrSecond+1;
}
else
{int myCounter=0;
Serial.println(" Intruder still present");
do
{
analogWrite(11,250);
toneAC(250,5);
delay(250);
toneAC(1500,5);
delay(250);
myCounter = myCounter + 1;}
while(myCounter<30);
}
}
}
}

Can you link me to this toneAC library?

Can you define, "Doesn't work". What happens? How does that compare with what you expected?

Please read the "how to use the forum" stickies to see how to format and post code. A description of what the sketch is supposed to do and what it really does will help us to give informed advice. "It doesn't work" is not enough information (if it worked, would you be here)? Post the complete text of the error messages, too.

I get this error:
libraries/toneAC/toneAC.cpp.o (symbol from plugin): In function noToneAC()': (.text+0x0): multiple definition of __vector_11'
libraries/Servo/avr/Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

I liked the toneAC because I wanted to control the frequency and the volume of the note. Here is a link to the toneAC library.
http://playground.arduino.cc/Code/ToneAC

If I break the program into two programs, one for the servo, one for the piezo, each including only one library it works just fine....

Thank you!

Both of those libraries are trying to use the same timer interrupt. You just can't use the two at the same time. There is another servo library out there that uses timer 2.

Thanks so much, this makes sense. Can you recommend a library that uses timer 2. First googling attempt did not produce anything meaningful.

Also, thanks to everyone for being patient with me, this is the first time I posted on this forum, still learning!

This is really old, so it's probably not up to date. But it should get you moving in the right direction.

http://forum.arduino.cc/index.php?topic=21975.0

This may be more up to date: