-
Notifications
You must be signed in to change notification settings - Fork 1
/
part1_sketch.ino
101 lines (82 loc) · 1.97 KB
/
part1_sketch.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <SoftwareSerial.h>
//define for temperature sensor
int sensorInput;
int tempsensePin=A4;
int temp;
int ledPin_temp =7;
int threshold_temperature=15;
//define eye blink senaor
int BUZZER = 13;
//define alcohol sensor
const int MQ3=0;
int value;
void setup() {
Serial.begin(9600);
//setup for temperature
pinMode(tempsensePin, INPUT);
pinMode(sensorInput,INPUT);
pinMode(ledPin_temp, OUTPUT);
//setup for eye blink sensor
pinMode (BUZZER, OUTPUT);
//setup for alcohol sensor
pinMode(MQ3, INPUT);
digitalWrite(BUZZER,LOW);
digitalWrite(ledPin_temp,LOW);
}
void loop() {
//temperature sensor detection and prevention by red light on
sensorInput = analogRead(A4);
temp = sensorInput*0.048828125;
//alcohol sensor detection
value= analogRead(MQ3);
Serial.print("alcohol concentration is: ");
Serial.println(value);
// Check if Bluetooth module has received a signal
while(Serial.available() > 0 || temp>threshold_temperature || value>130) {
// Read the incoming signal from the Bluetooth module
int bluetoothSignal = Serial.read();
// Check if the signal is equal to 1
sensorInput = analogRead(A4);
temp = sensorInput*0.048828125;
//alcohol sensor detection
value= analogRead(MQ3);
Serial.print("alcohol concentration is: ");
Serial.println(value);
if(value>130)
{
digitalWrite(BUZZER, HIGH);
delay(200);
}
else{
digitalWrite(BUZZER, LOW);
delay(200);
}
if (bluetoothSignal == '1') {
// Turn on the buzzer
digitalWrite(BUZZER, HIGH);
delay(200);
}
else{
digitalWrite(BUZZER, LOW);
delay(200);
}
if (temp>threshold_temperature)
{
digitalWrite(ledPin_temp,HIGH);
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println("C");
Serial.print('\n');
Serial.print("Warning!!!");
Serial.print('\n');
Serial.print("Temprature is High");
Serial.print('\n');
}
else
{
digitalWrite(ledPin_temp,LOW);
Serial.print("Temp is fine");
Serial.print('\n');
}
}
}