My favorites | Sign in
Project Logo
                
Repository:
Checkout | Browse | Changes | Clones |
 
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
// Scott Kirkwood
// Original code from Bruce Allen 23/Jul/09

const int pwPin = 7; // define pw pin for LV-MaxSonar-EZ1
const int camPin = 13; //define a pin for Camera
const int distance = 20; // cm
//variables needed to store values
long pulse, inches, cm;
int low_count = 0;
#define BATTERY 0
void setup() {
if (!BATTERY) {
Serial.begin(9600); //Begin serial communcation
Serial.println("Ready for Canon Remote Trigger");
}
all_output();
pinMode(camPin, OUTPUT); // sets the digital pin as output
pinMode(pwPin, INPUT);
delay(1000); // Wait for MaxSonar to calibrate.
}

// This should lower the juice used on the board
void all_output() {
for (int i = 0; i < 16; i++) {
pinMode(i, OUTPUT);
}
}

void shoot() {
if (!BATTERY) {
Serial.println("Shooting");
}
digitalWrite(camPin, HIGH);
delay(800);
digitalWrite(camPin, LOW);
delay(100);
digitalWrite(camPin, HIGH);
delay(500);
digitalWrite(camPin, LOW);
delay(50);
}

int distance_cm() {
//Used to read in the pulse that is being sent by the MaxSonar device.
//Pulse Width representation with a scale factor of 147 uS per Inch.
pulse = pulseIn(pwPin, HIGH);
//147uS per inch
inches = pulse/147;
//change inches to centimetres
return inches * 2.54;
}

void loop() {
cm = distance_cm();
if (!BATTERY) {
Serial.print("Distance ");
Serial.println(cm);
}
if (cm < distance) {
low_count++;
if (low_count > 2) {
shoot();
delay(3000);
low_count = 0;
}
}
delay(500);
}
Show details Hide details

Change log

15a6ca8638 by scottkir...@asta-laptop on Oct 10, 2009   Diff
Added interval.lua (one that works!)
Updated myshutter and CanonRemoteTrigger.
Go to: 
Project members, sign in to write a code review

Older revisions

088455f199 by Scott Kirkwood <scottakirkwood> on Oct 05, 2009   Diff
Halloween LED code. Canon Remote
Trigger code
All revisions of this file

File info

Size: 1532 bytes, 68 lines
Hosted by Google Code