int gas = 0;
int pinAlarma = 8;
void setup() {
// put your setup code here, to run once:
pinMode(A0,INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
gas = analogRead(A0);
Serial.print("GLP: ");
Serial.print(gas);
Serial.println(" ppm");
if (gas > 100) {
tone(pinAlarma, 1000, 500); // play tone 60 (C5 = 523 Hz)
} else {
noTone(pinAlarma);
}
delay(500); // Delay a little bit to improve simulation performance
}