-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisparador-camera.ino
More file actions
89 lines (70 loc) · 1.62 KB
/
disparador-camera.ino
File metadata and controls
89 lines (70 loc) · 1.62 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
/**
* Controlando câmera NewLink Sport Mini
*
* O script liga a câmera, troca para modo desejado
* e tira uma foto a cada aproximadamente, 64 segundos.
*
* @author Thiago Paes <mrprompt@gmail.com>
*/
#define PINO_FOTO 2
#define PINO_FORCA 3
#define PINO_MODO 4
#define INTERVALO_FOTO 60000 // uma foto por minuto
#define MODO_CAMERA 4
boolean ligado;
boolean onCam;
long ultimaFoto;
void setup() {
Serial.begin(9600);
pinMode(PINO_FORCA, OUTPUT);
pinMode(PINO_FOTO, OUTPUT);
pinMode(PINO_MODO, OUTPUT);
ligado = false;
onCam = false;
ultimaFoto = 0;
}
void loop() {
startCam();
tiraFoto();
delay(1000);
}
/**
* Liga a câmera e coloca no modo correto
* definido em MODO_CAMERA.
*
* Modos da câmera:
*
* 1 & 2 = vídeo (baixa e alta resolução, respectivamente)
* 3 & 4 = foto (baixa e alta resolução, respectivamente)
*/
void startCam() {
if (ligado == false) {
Serial.println("ligando");
digitalWrite(PINO_FORCA, HIGH);
delay(1000);
digitalWrite(PINO_FORCA, LOW);
delay(1000);
for (int i = 1; i <= MODO_CAMERA; i++) {
digitalWrite(PINO_MODO, HIGH);
delay(1000);
digitalWrite(PINO_MODO, LOW);
delay(1000);
if (i == MODO_CAMERA) {
onCam = true;
ligado = true;
}
}
}
}
void tiraFoto() {
if (ligado == true && onCam == true && (millis() - ultimaFoto > INTERVALO_FOTO)) {
Serial.println("tirando foto");
digitalWrite(PINO_FOTO, HIGH);
delay(1000);
digitalWrite(PINO_FOTO, LOW);
delay(1000);
ultimaFoto = millis();
Serial.println();
}
Serial.print('.');
}