-
Notifications
You must be signed in to change notification settings - Fork 2
/
arduino.c
57 lines (49 loc) · 1.25 KB
/
arduino.c
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
// Number of pictures to take
#define shots 100
// How far to advance between shots
// 128 steps == 1 mark on the fine control == 1 micron
#define MICRON 128L
#define distance (17 * MICRON)
//Declare pin functions on Arduino
#define stp 2
#define dir 3
#define fire 13
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(fire, OUTPUT);
digitalWrite(stp, LOW);
digitalWrite(dir, HIGH);
Serial.begin(9600); //Open Serial connection for debugging
}
//Main loop
void loop() {
long int i, j;
char input;
Serial.println("Press Enter to start");
do {
input = Serial.read();
} while (input != '\n');
for (i = 0; i < shots; i++) {
trigger();
for (j = 0; j < distance; j++) {
step();
}
}
}
// Power on the IR trigger circuit to fire the camera
void trigger()
{
delay(1000); // wait for vibration to settle
digitalWrite(fire, HIGH); // take the picture
delay(2000); // wait for that to happen
digitalWrite(fire, LOW); // disable the IR circuit again
}
// Advance the motor by one step
void step()
{
digitalWrite(stp, HIGH); //Trigger one step forward
delay(1);
digitalWrite(stp, LOW); //Pull step pin low so it can be triggered again
delay(1);
}