-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRISTI_Sensor_NANO.ino
34 lines (34 loc) · 1.05 KB
/
SRISTI_Sensor_NANO.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int count=0;
int count2=0;
const int BuzzerPin1 = 12;
const int BuzzerPin2 = 8;
void setup()
{
pinMode(BuzzerPin1, OUTPUT);
pinMode(BuzzerPin2, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int sensorValue_MQ135 = analogRead(A0);
Serial.print("Air Quality from MQ135= ");
Serial.print(sensorValue_MQ135);
Serial.print("\n");
Serial.println();
delay(1000);
//algorithm
if (sensorValue_MQ135 > 840) {
count++ ; //counter function value increases to 1,2,3,4 and 5;
}
else if (count!=0){
count = 0; //counter function value nullifies to 0 if consequitive term is not = 0;
}
if (count == 3){ //buzzer will only activate if consequitive 5 values for MQ7 sensor comes above 500;
digitalWrite(BuzzerPin1, HIGH);
digitalWrite(BuzzerPin2, LOW);
delay(1000);
digitalWrite(BuzzerPin1, LOW);
digitalWrite(BuzzerPin2, LOW);
count = 0; // counter function returns to original value;
}
}