CIRCUIT:-
CODE:-
int BUZZER = 11;
int GAS_SENSOR = A0;
int SENSORTHRESHOLD = 200;
void setup() {
Serial.begin(9600);
pinMode(BUZZER, OUTPUT);
pinMode(GAS_SENSOR, INPUT);
}
void loop() {
int SENSOR = analogRead(GAS_SENSOR);
if(SENSOR-50 > SENSORTHRESHOLD){
tone(BUZZER, 1000); // Send 1KHz sound signal...
delay(500); // ...for 1 sec
noTone(BUZZER); // Stop sound...
delay(500); // ...for 1sec
}
Serial.println(SENSOR-50);
}
0 Comments
Please do not Enter any Spam Link in the Comment Box
Emoji