Skip to content

Commit 2fef4ed

Browse files
committed
Full codes
1 parent 03de6b8 commit 2fef4ed

File tree

3 files changed

+122
-14
lines changed

3 files changed

+122
-14
lines changed

buzzer/buzzer.ino

Whitespace-only changes.

full/full.ino

+111-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,111 @@
1-
//Hello
1+
#include <Wire.h>
2+
#include <Adafruit_MLX90614.h>
3+
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
4+
//Sonar 1
5+
int echoPin1 = 3;
6+
int initPin1 = 2;
7+
int distance1 =0;
8+
9+
//Sonar 2
10+
int echoPin2 = 9;
11+
int initPin2 = 7;
12+
int distance2 =0;
13+
14+
int piezoPin = 8;
15+
int vibrator = 4;
16+
17+
int isDisSensor = 0;
18+
int isDisSensor2 = 0;
19+
int tempp = 0;
20+
void setup() {
21+
mlx.begin();
22+
pinMode(initPin1, OUTPUT);
23+
pinMode(echoPin1, INPUT);
24+
pinMode(initPin2, OUTPUT);
25+
pinMode(echoPin2, INPUT);
26+
pinMode(vibrator, OUTPUT);
27+
}
28+
29+
void loop() {
30+
digitalWrite(vibrator,LOW);
31+
tempp = mlx.readObjectTempC();
32+
distance1 = getDistance(initPin1, echoPin1);
33+
distance2 = getDistance(initPin2, echoPin2);
34+
if (tempp >= 30){
35+
son1();
36+
}
37+
if (distance1 <= 40){
38+
son2();
39+
}
40+
if (distance1 <= 20){
41+
son3();
42+
}
43+
if (distance2 <= 40){
44+
son4();
45+
}
46+
if (distance2 <= 20){
47+
son5();
48+
}
49+
}
50+
int getDistance (int initPin, int echoPin){
51+
digitalWrite(initPin, HIGH);
52+
delayMicroseconds(10);
53+
digitalWrite(initPin, LOW);
54+
55+
unsigned long pulseTime = pulseIn(echoPin, HIGH);
56+
int distance = pulseTime/58;
57+
return distance;
58+
59+
}
60+
void son1(){
61+
//Fire detected
62+
tone(piezoPin, 1000, 500);
63+
delay(1000);
64+
digitalWrite(vibrator,HIGH);
65+
delay(500);
66+
}
67+
void son2(){
68+
//UP high distance
69+
tone(piezoPin, 1000, 500);
70+
delay(700);
71+
digitalWrite(vibrator,HIGH);
72+
delay(100);
73+
digitalWrite(vibrator,LOW);
74+
delay(100);
75+
digitalWrite(vibrator,LOW);
76+
delay(100);
77+
}
78+
void son3(){
79+
//UP low distance
80+
tone(piezoPin, 1000, 500);
81+
delay(500);
82+
digitalWrite(vibrator,HIGH);
83+
delay(300);
84+
digitalWrite(vibrator,LOW);
85+
delay(300);
86+
digitalWrite(vibrator,LOW);
87+
delay(300);
88+
}
89+
void son4(){
90+
//Down high distance
91+
tone(piezoPin, 1000, 500);
92+
delay(1500);
93+
digitalWrite(vibrator,HIGH);
94+
digitalWrite(vibrator,HIGH);
95+
delay(700);
96+
digitalWrite(vibrator,LOW);
97+
delay(700);
98+
digitalWrite(vibrator,LOW);
99+
delay(700);
100+
}
101+
void son5(){
102+
//Down low distance
103+
tone(piezoPin, 1000, 500);
104+
delay(1300);
105+
digitalWrite(vibrator,HIGH);
106+
delay(1000);
107+
digitalWrite(vibrator,LOW);
108+
delay(1000);
109+
digitalWrite(vibrator,LOW);
110+
delay(1000);
111+
}

temperature/temperature.ino

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1+
#include <Wire.h>
12
#include <Adafruit_MLX90614.h>
2-
33
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
4-
5-
void setup()
6-
{
7-
Serial.begin(9600);
8-
mlx.begin();
9-
}
10-
11-
void loop()
12-
{
13-
float temperature = mlx.readObjectTempC();
14-
Serial.println(temperature);
15-
delay(500);
4+
void setup() {
5+
Serial.begin(9600);
6+
mlx.begin();
167
}
8+
void loop() {
9+
10+
Serial.print("Celsius : ");
11+
Serial.print(mlx.readObjectTempC());
12+
Serial.println();
13+
delay(500);
14+
}

0 commit comments

Comments
 (0)