-
Notifications
You must be signed in to change notification settings - Fork 0
/
BLE_Camera.ino
44 lines (39 loc) · 1.04 KB
/
BLE_Camera.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
/*
* Programmer: Josh Deese
* Date: March, 14, 2013
* Purpose: Receive serial command 'F' or 'S' from iPhone via Bluetooth 4.0
* Problems: Camera will not take picture until it decides it is focused if lens
* is in af mode. There is no way of determining if the camera is focused,
* even after the 5000ms of focus after an 'F' command.
*/
#include <SoftwareSerial.h>
SoftwareSerial bleShield(2, 3);
long previousMillis = 0;
long interval = 1000;
int led = 13;
int focus = 4;
int shutter = 5;
void setup(){
// set the data rate for the SoftwareSerial port
bleShield.begin(19200);
Serial.begin(19200);
pinMode(focus, OUTPUT);
pinMode(shutter, OUTPUT);
}
void loop(){
if(bleShield.available()) {
char command;
command = bleShield.read();
if(command == 'F'){
// Focus Camera
digitalWrite(focus, HIGH);
delay(5000);
digitalWrite(focus, LOW);
} else if(command == 'S'){
// Take Picture
digitalWrite(shutter, HIGH);
delay(100);
digitalWrite(shutter, LOW);
}
}
}