Hi, I am doing a tripwire alarm using laser emitter and ldr. I want to have a loud noise so I decided to use the toneAC library instead of the standard tone library. I want to have a dual tone with different frequency beeping. However after I powered the Arduino, the buzzer is giving me a single tone only. Can someone have a look at my code? I am not familiar with this toneAC library.
#include <toneAC.h>
#define Rec A0
#define Laser 2
void setup() {
pinMode(Rec, INPUT);
pinMode(Laser, OUTPUT);
digitalWrite(Laser,HIGH);
delay(2000);
Serial.begin(9600);
}
void loop() {
int sensorVal = analogRead(Rec);
Serial.println(sensorVal);
if(sensorVal<300){
toneAC(1500);
delay(100);
toneAC(2500);
delay(100);
}
else
toneAC(0);
while(1);
}