     while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
     }
-
     Serial.print("Setup Camera Relay Pins ... ");
     pinMode(camera1_pin, OUTPUT);
     pinMode(camera2_pin, OUTPUT);

    Serial.println("done!");
}

//-----------------------------------------------------------------------------
// MAIN LOOP
//-----------------------------------------------------------------------------
void loop() {
    // if there's any serial available, read it:
    while (Serial.available() > 0) {
        int command = Serial.parseInt();
        // Based on the command, parse the rest of the serial string differently.
        if (command == 69) {
            // Expose (E=69) command
            int camera1 = Serial.parseInt();
            int camera2 = Serial.parseInt();
            int exptime_ms = Serial.parseInt();
            // look for the newline. That's the end of your
            // sentence:
            if (Serial.read() == '\n') {
                // expose camera for exptime_ms milliseconds
                Serial.print("Starting ");
                Serial.print(exptime_ms/1000.0);
                Serial.print(" second exposure");
                if (camera1 >= 1) {
                    Serial.print(" on camera1 ");
                    digitalWrite(camera1_pin, HIGH);
                    if (camera2 >= 1) { Serial.print("and"); }
                }
                if (camera2 >= 1) {
                    Serial.print(" on camera2 ");
                    digitalWrite(camera2_pin, HIGH);
                }
                Serial.print("... ");
                // Now go in to loop waiting for exposure time to finish
                // If a cancel command is received, cancel exposure.
                int total_exptime = 0;
                int remainder = total_exptime % 100;
                int n_loops = (total_exptime - remainder) / 100;
                for (int index = 0; index < n_loops; index++) {
                    delay(100);
                    total_exptime = total_exptime + 100;
                    // Look for cancel command
                }
                delay(remainder);
                // Set pins low (stop exposure)
                digitalWrite(camera1_pin, LOW);
                digitalWrite(camera2_pin, LOW);
                Serial.println("done");
            }
        }
        if (command == 67) {
            // Cancel (C=67) command
        }
        if (command == 81) {
            // Query (Q=81) command
        }
    }
    delay(100);
}


time in milliseconds.

Serial Commands to Board:
Enn,mmmmmm -- Expose camera for mmmmmm milliseconds.
C          -- Cancel exposure.  Cancels exposure on both cameras.
Q          -- Query which cameras are exposing.
T          -- Query temperature and humidity from DHT22 (only works if camera not exposing)
O          -- Query orientation (only works if camera not exposing)
*/

char Command[3];
char Data[7];
const int bSize = 20; 
char Buffer[bSize];  // Serial buffer
int ByteCount;

int camera1_pin = 2;
int camera2_pin = 4;

//Analog read pins
const int xPin = 0;
const int yPin = 1;
const int zPin = 2;

//The minimum and maximum values that came from
//the accelerometer while standing still
//You very well may need to change these
int minVal = 265;
int maxVal = 402;

//to hold the caculated values
double x;
double y;
double z;

//-----------------------------------------------------------------------------
// SerialParser
//-----------------------------------------------------------------------------
void SerialParser(void) {
    ByteCount = -1;
    ByteCount =  Serial.readBytesUntil('\n',Buffer,bSize);
    if (ByteCount  > 0) {
        strcpy(Command,strtok(Buffer,","));
        strcpy(Data,strtok(NULL,","));
    }
    memset(Buffer, 0, sizeof(Buffer));   // Clear contents of Buffer
    Serial.flush();
}


//-----------------------------------------------------------------------------
// SETUP
