-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomoSecure.ino
More file actions
90 lines (81 loc) · 2.23 KB
/
DomoSecure.ino
File metadata and controls
90 lines (81 loc) · 2.23 KB
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
const int PIRPin = 2;
int PIRState = LOW;
const int LEDPin = 13;
void setup()
{
pinMode(PIRPin, INPUT);
pinMode(LEDPin, OUTPUT);
Serial.begin(115200);
while (!Serial){
; // wait for serial port to connect. Needed for native USB
}
}
void loop()
{
pirSensor();
if (Serial.available())
receivedData();
delay(1); // delay in between reads for stability
}
void pirSensor()
{
int value = digitalRead(PIRPin);
if (value == HIGH) //detect movement.
{
if (PIRState == LOW)
{ // code to make a camera shoot by python.
Serial.write(1);
PIRState = HIGH;
}
}
else
{
if (PIRState == HIGH)
{ // code to stop a camera shoot by python.
Serial.write(0);
PIRState = LOW;
}
}
}
void receivedData()
{// data receive from the python software after analize the picture taken.
// 0-ok, 1-ko, #?-blink.
char danger = Serial.read();
switch (danger)
{
case '0': //green rect.. know faces.. todo bien.
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
delay(500);
digitalWrite(LEDPin, HIGH);
delay(500);
digitalWrite(LEDPin, LOW);
break;
case '1': //red rect.. unknow faces.. algo mal.
digitalWrite(LEDPin, HIGH);
delay(8000);
digitalWrite(LEDPin, LOW);
break;
default:
digitalWrite(LEDPin, LOW);
}
}