/*
SkySweep 2.041 for SkyShield v 2.0 with a 4-switch DIP
A sketch to operate the SkyShield, a custom shield for the Arduino Nano which allows autonomous control of a kite aerial photography rig.
The sketch controls servos for tilting and panning the camera and a 5V pulse is sent to trigger the camera shutter during pauses in servo motion.
The pan servo is a continuous rotation servo, the tilt servo is a standard servo. Both are micro servos.
Tilt positions are set in arrays, and the number of pan positions at each tilt angle is set in arrays.
The number of pan positions varies with the tilt angle of the camera (for modes with pans nested within tilts).
Sixteen modes (regimes of pan/tilt/shoot) can be selected in the field with a 4-switch DIP switch.
A pulse is sent to the USB port of Canon PowerShots running CHDK and an LED on the Nano is lit for the duration of the pulse.
CHDK must be active on the camera with remote shutter enabled (one push, quick).
Timing will depend on the particular servos and battery strength and can be adjusted by changing the delay values in this sketch.
Includes modes for lenses of 24mm, 28mm, and 37mm focal length.
Modes 8 through 15 are repeats of Modes 0 through 7 as placeholders.
Version 2.041 by C. Fastie 7/3/15
*/
#include // Include the servo library
// For tilt control
Servo tiltServo; // Assign tilt servo.
// Modify the following arrays for different tilt angles.
int tiltAngle5[]= {124, 95, 70, 45, 20}; // Establish an array for five tilt positions
int tiltAngle4[]= {124, 86, 53, 20}; // Establish an array for four tilt positions
int tiltAngle3[]= {100, 70, 40}; // Establish an array for three tilt positions
// For pan control
Servo panServo; // Assign pan servo
int pan; // variable for pan position counter
int fullPan = 2130; // variable for 360 degree pan increment time (milliseconds). Modify this number to tune the pan angles.
int sweepTime; // variable for the number of milliseconds to pan
int panPos; // variable for how many pan positions at this tilt angle
// Modify the following arrays for different numbers of pan positions at each tilt angle.
int panPos8[]= {8, 8, 6, 3}; // Establish an array for decreasing pan positions (from uppermost to lowermost tilt angle). 24mm lens
int panPos9[]= {9, 9, 8, 6, 3}; // Establish an array for decreasing pan positions (from uppermost to lowermost tilt angle). 28mm lens
int panPos10[]= {10, 10, 9, 7, 4}; // Establish an array for decreasing pan positions (from uppermost to lowermost tilt angle). 37mm lens
// For camera control
int LEDPin = 13; // Assign LEDPin on the Nano to a pin number
int shutterPin0 = A0; // Assign ShutterPin0 to a pin number
int shutterPin1 = A1; // Assign ShutterPin1 to a pin number
// For mode selection
int mode = 0; // variable: which of the modes is active
int switchPin1 = A2; // Each DIP switch is connected to different analog pin
int switchPin2 = A3; //
int switchPin3 = A4; //
int switchPin4 = A5; //
int pinStatus1; // variable for reading the pin status (High or LOW)
int pinStatus2; //
int pinStatus3; //
int pinStatus4; //
void setup()
{
pinMode(switchPin1, INPUT_PULLUP); // sets the pin named switchPinX as an INPUT_PULLUP pin (uses resistor on Nano)
pinMode(switchPin2, INPUT_PULLUP); //
pinMode(switchPin3, INPUT_PULLUP); //
pinMode(switchPin4, INPUT_PULLUP); //
pinMode(shutterPin1, OUTPUT); // sets the pin named shutterPinx as an output pin
pinMode(shutterPin0, OUTPUT); //
pinMode(LEDPin, OUTPUT); // sets the pin named LEDPin as an output pin
tiltServo.attach(9); // attaches the servo named tiltServo to pin D9
panServo.attach(6); // attaches the servo named panServo to pin D6
// Read the user selected mode from the positions of the DIP switch:
pinStatus1 = digitalRead(switchPin1); // read the state of SwitchPinX and store it in pinStatusX
pinStatus2 = digitalRead(switchPin2); //
pinStatus3 = digitalRead(switchPin3); //
pinStatus4 = digitalRead(switchPin4); //
if (pinStatus1 == LOW) // if DIP switch 1 is ON (for pull up resistor)...
mode = 8; // the mode is at least 8
else mode = 0; // if DIP switch 1 is OFF, the mode is < 4
if (pinStatus2 == LOW) // if DIP switch 2 is ON (for pull up resistor)...
mode = mode + 4; // the mode is at least 4
if (pinStatus3 == LOW) // if DIP switch 3 is ON (for pull up resistor)...
mode = mode + 2; // the mode is at least 2
if (pinStatus4 == LOW) // if DIP switch 4 is ON (for pull up resistor)...
mode = mode + 1; // the mode is at least 1
}
void loop()
{
if(mode == 0) // Slow 360: 3 to 8 pan positions nested within 4 tilt positions for 24 mm lens
{
// Tilt Control:
for(int a = 0; a <=3 ; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(1000); // wait after tilt servo motion to take a photo
if(a < 1) delay(300); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos8[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while(pan < panPos) // pan to each position
{
// Shutter Control:
delay(1200); // wait for the rig to settle before triggering shutter
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1100); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
pan++; // increment the pan position counter
} // end while
} // end for
} // end if
if(mode == 1) // Fast 360: 3 to 8 pan positions nested within 4 tilt positions for 24 mm lens
{
// Tilt Control:
for(int a = 0; a <=3 ; a++) // run through the array of 4 tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(700); // wait after tilt servo motion to take a photo
if(a < 1) delay(300); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos8[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(900); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment the pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1000); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 2) // Slow 360: 3 to 9 pan positions nested within 5 tilt positions for 28 mm lens
{
// Tilt Control:
for(int a = 0; a <=4 ; a++) // run through the array of 5 tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1200); // wait after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos9[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1300); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1300); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 3) // Fast 360: 3 to 9 pan positions nested within 5 tilt positions for 28 mm lens
{
for(int a = 0; a <=4 ; a++) // run through the array of tilt angles
{
// Tilt Control:
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(900); // wait after tilt servo motion to take a photo
if(a < 1) delay(400); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos9[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(900); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(900); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 4) // Fast 360 5x9: 5 tilt positions nested within 9 pan positions
{
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(230); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
for(int a=0; a<=4; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(900); // wait after tilt servo motion to take a photo
if(a<1) delay(300); // wait longer during the big tilt back up to the first position
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(200); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(2000); // wait for the camera to finish taking photo before next servo motion
} // end for loop
} // end if
if(mode == 5) // Slow 360 5x9: 5 tilt positions nested within 9 pan positions
{
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(230); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
for(int a=0; a<=4; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1000); // wait (1 second) after tilt servo motion to take a photo
if(a<1) delay(300); // wait longer during the big tilt back up to the first position
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(2500); // wait for the camera to finish taking photo before next servo motion
} // end for loop
} // end if
if(mode == 6) // Slow 360: 4 to 10 pan positions nested within 5 tilt positions for 37 mm lens
{
// Tilt Control:
for(int a = 0; a <=4 ; a++) // run through the array of 5 tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1200); // wait after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos10[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1300); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1300); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 7) // 180+ degree 4x4: 4 pan positions nested within 4 tilt positions for 24 mm lens (with nadir and above horizon)
{
for(int a = 0; a <=3 ; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(1000); // wait (1 second) after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
pan = 0; // initialize the pan position variable
while (pan < 4) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1100); // wait for the camera to finish taking photo before next servo motion
if (pan < 3){ // if another pan movement is needed
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(255); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1200); // wait for the rig to settle before triggering shutter
} // end if
pan++; // increment the pan position variable
} // end while
panServo.write(164); // else, move the pan servo back toward the starting position.
delay(795); // let the servo turn for a number of milliseconds
panServo.write(90); // stop the servo and hold its position
delay(1200); // wait for the rig to settle before triggering shutter
} // end for
} // end if
if(mode == 8) // Slow 360: 3 to 8 pan positions nested within 4 tilt positions for 24 mm lens
{
// Tilt Control:
for(int a = 0; a <=3 ; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(1000); // wait after tilt servo motion to take a photo
if(a < 1) delay(300); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos8[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while(pan < panPos) // pan to each position
{
// Shutter Control:
delay(1200); // wait for the rig to settle before triggering shutter
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1100); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
pan++; // increment the pan position counter
} // end while
} // end for
} // end if
if(mode == 9) // Fast 360: 3 to 8 pan positions nested within 4 tilt positions for 24 mm lens
{
// Tilt Control:
for(int a = 0; a <=3 ; a++) // run through the array of 4 tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(700); // wait after tilt servo motion to take a photo
if(a < 1) delay(300); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos8[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(900); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment the pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1000); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 10) // Slow 360: 3 to 9 pan positions nested within 5 tilt positions for 28 mm lens
{
// Tilt Control:
for(int a = 0; a <=4 ; a++) // run through the array of 5 tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1200); // wait after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos9[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1300); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1300); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 11) // Fast 360: 3 to 9 pan positions nested within 5 tilt positions for 28 mm lens
{
for(int a = 0; a <=4 ; a++) // run through the array of tilt angles
{
// Tilt Control:
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(900); // wait after tilt servo motion to take a photo
if(a < 1) delay(400); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos9[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(900); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(900); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 12) // Fast 360 5x9: 5 tilt positions nested within 9 pan positions
{
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(230); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
for(int a=0; a<=4; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(900); // wait after tilt servo motion to take a photo
if(a<1) delay(300); // wait longer during the big tilt back up to the first position
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(200); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(2000); // wait for the camera to finish taking photo before next servo motion
} // end for loop
} // end if
if(mode == 13) // Slow 360 5x9: 5 tilt positions nested within 9 pan positions
{
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(230); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
for(int a=0; a<=4; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1000); // wait (1 second) after tilt servo motion to take a photo
if(a<1) delay(300); // wait longer during the big tilt back up to the first position
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(2500); // wait for the camera to finish taking photo before next servo motion
} // end for loop
} // end if
if(mode == 14) // Slow 360: 4 to 10 pan positions nested within 5 tilt positions for 37 mm lens
{
// Tilt Control:
for(int a = 0; a <=4 ; a++) // run through the array of 5 tilt angles
{
tiltServo.write(tiltAngle5[a]); // tilt to next angle in the array
delay(1200); // wait after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
// Pan Control:
pan = 0; // initialize the pan position counter
panPos = panPos10[a]; // fill a variable panPos (how many pan positions) from an array. Depends on the current tilt angle.
while (pan < panPos) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1300); // wait for the camera to finish taking photo before next servo motion
// Do the pan move:
sweepTime = fullPan/panPos; // Compute the pan increment time. fullPan is the time for a full 360° pan.
pan++; // increment pan position counter
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(sweepTime); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1300); // wait for the rig to settle before triggering shutter
} // end while
} // end for
} // end if
if(mode == 15) // 180+ degree 4x4: 4 pan positions nested within 4 tilt positions for 24 mm lens (with nadir and above horizon)
{
for(int a = 0; a <=3 ; a++) // run through the array of tilt angles
{
tiltServo.write(tiltAngle4[a]); // tilt to next angle in the array
delay(1000); // wait (1 second) after tilt servo motion to take a photo
if(a < 1) delay(500); // wait longer during the big tilt back up to the first position
pan = 0; // initialize the pan position variable
while (pan < 4) // pan to each position
{
// Shutter Control:
digitalWrite(LEDPin, HIGH); // send current to the LED on the Nano
digitalWrite(shutterPin0, HIGH); // start to send current to the camera USB port
delay(250); // send current to the USB port for this long
digitalWrite(shutterPin0, LOW); // drop the current to the USB port to zero
digitalWrite(LEDPin, LOW); // turn LED off
delay(1100); // wait for the camera to finish taking photo before next servo motion
if (pan < 3){ // if another pan movement is needed
panServo.write(16); // Start the pan servo turning at the designated speed and direction.
delay(255); // let the servo turn for a number of milliseconds. This determines how much the rig rotates (pans).
panServo.write(90); // stop the servo and hold its position
delay(1200); // wait for the rig to settle before triggering shutter
} // end if
pan++; // increment the pan position variable
} // end while
panServo.write(164); // else, move the pan servo back toward the starting position.
delay(795); // let the servo turn for a number of milliseconds
panServo.write(90); // stop the servo and hold its position
delay(1200); // wait for the rig to settle before triggering shutter
} // end for
} // end if
}