-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch_may8a.ino
More file actions
31 lines (29 loc) · 876 Bytes
/
sketch_may8a.ino
File metadata and controls
31 lines (29 loc) · 876 Bytes
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
//put this code for LED in the ide of arduino from this line
int LED = 9;
int ALCOHOL_sensor = 2;// MQ-6 SENSOR
int ALCOHOL_detected;
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(ALCOHOL_sensor, INPUT);
}
void loop()
{
delay(2000);
ALCOHOL_detected = digitalRead(ALCOHOL_sensor);
Serial.println(ALCOHOL_detected);
int analog=analogRead(A1);
Serial.print("Analog Read: ");
Serial.println(analog);
if (analog>300)
{
Serial.println("ALCOHOL detected...");
digitalWrite(LED, HIGH);
}
else
{
Serial.println("No ALCOHOL detected ");
digitalWrite(LED, LOW);
}
}