-
Notifications
You must be signed in to change notification settings - Fork 4
/
Alcohol_Sensor_MQ3.ino
45 lines (38 loc) · 1.13 KB
/
Alcohol_Sensor_MQ3.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
35
36
37
38
39
40
41
42
43
44
45
int limit= 420;
float alc;
const int buzzer=2;
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(7, OUTPUT);
pinMode(8,OUTPUT);
pinMode(10,OUTPUT);
pinMode(buzzer,OUTPUT);
}
void loop() {
alc=analogRead(A0);
Serial.println(alc);
float percentage=(alc/10000);
Serial.println(percentage);
Serial.println(' ');
if(alc > limit)
{
Serial.println("THE ALCOHOL CONTENT IS OVER THE LIMIT");
Serial.println("ENGINE IS SWITCHED OFF");
digitalWrite(13, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
tone(buzzer, 660,250);
tone(buzzer, 700,250);
tone(buzzer, 800,250);
}
else{
Serial.println("THE ALCOHOL CONTENT IS UNDER THE LIMIT");
Serial.println("ENGINE IS SWITCHED ON");
digitalWrite(13, LOW);
digitalWrite(7,HIGH);
digitalWrite(10,HIGH);
}
delay(500);
}