// "Smoke Detector"
const int smokePin = A0;
const int triggerPin = A1;
const int buzzerPin = 13;
void setup()
{
Serial.begin(115200);
pinMode(buzzerPin,OUTPUT);
}
void loop()
{
int triggerValue = analogRead(triggerPin);
int smokeValue = analogRead(smokePin);
// Use the next second to either
// sound the buzzer or a silent delay.
int bps = 3; // beeps per second
if(smokeValue > triggerValue)
{
for(int i=0; i<bps; i++)
{
tone(buzzerPin,800);
delay(1000/(2*bps));
noTone(buzzerPin);
delay(1000/(2*bps));
}
}
else
{
delay(1000);
}
}
Set limit
Smoke Detector