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);
}
}
}
}