-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode
More file actions
34 lines (23 loc) · 615 Bytes
/
Copy pathCode
File metadata and controls
34 lines (23 loc) · 615 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
32
33
34
//The ultrasound sensor library
#include <HC_SR04/HC_SR04.h>
//Creating variables
int cm = 0;
//assigning the pins
int trigPin = D4;
int echoPin = D5;
//allocating the pins to the sensor
HC_SR04 rangeFinder = HC_SR04(trigPin, echoPin);
void setup()
{
}
void loop()
{
//measure the distance
cm = rangeFinder.getDistanceCM();
//vriable that contains the size of the door
int i = 158
//if statements to count the distance decrease to know someone has entered
if (cm < 158) Particle.publish("Someone entered", "Alert");
// Wait 1 seconds
delay(1000);
}