Need help with possible debounce? Inconsistent sensor switching.

So i’ve been trying to figure this out for a while on my own about 3-4 months. And i just don’t get it.

I know my code is crap this is the first project or anything i’ve ever done code for, So please bear with me I mostly have no idea what i’m doing.

So i have this programmed for a simple camera that just controls the Shutter aperture/speed, Indicator lights, And flash.

So the issue i’m running into is inconsistent Shutter activation. Sometimes the Shutter will stay open until the trigger is release or sometimes it won’t open at all. I would say it ranges from 3% of the time on a good day up to 20% of the time on a bad one.

Here’s my code if anyone has any advise on improving it and what i can do, I Would be soooo happy!

void setup() {
pinMode(2, INPUT_PULLUP); //GND SIGNAL MASTER (PIN 2)(PWM)
pinMode(3, OUTPUT); //FLASH READY ENABLE (PIN 3)
pinMode(4, OUTPUT); //FLASH GATE OPEN (PIN 4)
pinMode(5, OUTPUT); //GREEN LED (PIN 5)(PWM)
pinMode(6, OUTPUT); //RED LED (PIN 6)(PWM)
pinMode(7, OUTPUT); //FILM LED (PIN 7)
pinMode(15, OUTPUT); //SHUTTER CONTROL (PIN A1)
digitalWrite(15, HIGH);
// PHOTORESISTOR CONNECTS TO VR RIGHT LEG
// VR MIDDLE LEG CONNECTS TO AREF (PIN A0)
// VR LEFT LEG CONNECTS TO GROUND
}

void loop() {
while (digitalRead(2) == LOW) { //RUNS LOOP IF SHUTTER WOUND DURING HALF PRESS
void loop();
while (digitalRead(2) == HIGH) { //ENDS LOOP IF SHUTTER IS NOT WOUND DURING HALF PRESS
return; //MAGNET CONNECTS TO A1 AND GND
}

//DETECTS VOLTAGE REF FROM AREF
int sensorValue = analogRead(A0);
float voltage = sensorValue;
if (voltage >= 80) {
analogWrite(5, 180);
//GREEN LED ON IF VALUE MET
} else { (voltage < 80); { //VCC IS CONNECTED TO ORANGE WIRE
digitalWrite(5, HIGH);
//GND GREEN WIRE CONNECTED TO (PIN 5)
} //PULLS HIGH TO TURN OFF LED
}
if (voltage < 80) {
analogWrite(6, 180);
//RED LED ON IF VALUE NOT MET
} else { (voltage > 80); { //GND RED WIRE CONNECTED TO (PIN 6)
digitalWrite(6, HIGH); //PULLS HIGH TO TURN OFF LED
}
}
if (voltage <= 60 && voltage >= 0) { //SHUTTER PROFILE 1
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(50);
digitalWrite(15, LOW);
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 80 && voltage >= 60) { //SHUTTER PROFILE 2
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(44);
digitalWrite(15, LOW);
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 100 && voltage > 80) { //SHUTTER PROFILE 3
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(40);
digitalWrite(15, LOW);
digitalWrite(3, HIGH);
digitalWrite(3, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 120 && voltage > 100) { //SHUTTER PROFILE 4
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(38);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 135 && voltage > 120) { //SHUTTER PROFILE 5
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(36);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 150 && voltage > 135) { //SHUTTER PROFILE 6
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(34);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return ;}
}
if (voltage <= 165 && voltage > 150) { //SHUTTER PROFILE 7
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(32);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 180 && voltage > 165) { //SHUTTER PROFILE 8
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(28);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }
}
if (voltage <= 200 && voltage > 180) { //SHUTTER PROFILE 9
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(24);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return ;}
}
if (voltage <= 225 && voltage > 200) { //SHUTTER PROFILE 10
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(20);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return ;}
}
if (voltage <= 240 && voltage > 225) { //SHUTTER PROFILE 11
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(18);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return ;}
}
if (voltage <= 1024 && voltage > 240) { //SHUTTER PROFILE 12
digitalWrite(15, HIGH);
delay(15);
if (digitalRead(2) == HIGH) {
delay(16);
digitalWrite(15, LOW);
delay(50);
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
return; }

}
if (digitalRead(2) == HIGH)
digitalWrite(7, HIGH); //INDICATOR LED FOR FILM
delayMicroseconds(50);
digitalWrite(7, LOW);
}
if (digitalRead(2) == HIGH) { //TURNS OFF LEDS IF SHUTTER ISN’T WOUND
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
}

Let’s start by having the code better formatted and in code tags here so that it can more easily be copied to an editor

void setup() {
    pinMode(2, INPUT_PULLUP);    //GND SIGNAL MASTER  (PIN 2)(PWM)
    pinMode(3, OUTPUT);          //FLASH READY ENABLE (PIN 3)
    pinMode(4, OUTPUT);          //FLASH GATE OPEN    (PIN 4)
    pinMode(5, OUTPUT);          //GREEN LED          (PIN 5)(PWM)
    pinMode(6, OUTPUT);          //RED LED            (PIN 6)(PWM)
    pinMode(7, OUTPUT);          //FILM LED           (PIN 7)
    pinMode(15, OUTPUT);         //SHUTTER CONTROL    (PIN A1)
    digitalWrite(15, HIGH);
                    // PHOTORESISTOR CONNECTS TO VR RIGHT LEG
                    // VR MIDDLE LEG CONNECTS TO AREF (PIN A0)
                    // VR LEFT LEG CONNECTS TO GROUND
}                   

void loop() {
while (digitalRead(2) == LOW) {  //RUNS LOOP IF SHUTTER WOUND DURING HALF PRESS
    void loop();
while (digitalRead(2) == HIGH) { //ENDS LOOP IF SHUTTER IS NOT WOUND DURING HALF PRESS
    return;                     //MAGNET CONNECTS TO A1 AND GND
}

   //DETECTS VOLTAGE REF FROM AREF
  int sensorValue = analogRead(A0);
  float voltage = sensorValue;
  if (voltage >= 80) {
    analogWrite(5, 180);
                               //GREEN LED ON IF VALUE MET
    } else { (voltage < 80); {     //VCC IS CONNECTED TO ORANGE WIRE
    digitalWrite(5, HIGH);
                              //GND GREEN WIRE CONNECTED TO (PIN 5)
}                                   //PULLS HIGH TO TURN OFF LED
}
if (voltage < 80) {
    analogWrite(6, 180);
                                 //RED LED ON IF VALUE NOT MET
} else { (voltage > 80); {         //GND RED WIRE CONNECTED TO (PIN 6)
    digitalWrite(6, HIGH);          //PULLS HIGH TO TURN OFF LED
}
  }
if (voltage <= 60 && voltage >= 0)  { //SHUTTER PROFILE 1
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(50);
    digitalWrite(15, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(3, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
    return; }
}
if (voltage <= 80 && voltage >= 60)  { //SHUTTER PROFILE 2
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(44);
    digitalWrite(15, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(3, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
    return; }
}
if (voltage <= 100 && voltage > 80)  { //SHUTTER PROFILE 3
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(40);
    digitalWrite(15, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(3, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
}
if (voltage <= 120 && voltage > 100)  { //SHUTTER PROFILE 4
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(38);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
}
if (voltage <= 135 && voltage > 120)  { //SHUTTER PROFILE 5
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(36);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
}
if (voltage <= 150 && voltage > 135)  { //SHUTTER PROFILE 6
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(34);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return ;}
}
if (voltage <= 165 && voltage > 150)  { //SHUTTER PROFILE 7
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(32);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
}
if (voltage <= 180 && voltage > 165)  { //SHUTTER PROFILE 8
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(28);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
}
if (voltage <= 200 && voltage > 180)  { //SHUTTER PROFILE 9
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(24);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return ;}
}
if (voltage <= 225 && voltage > 200)  { //SHUTTER PROFILE 10
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(20);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return ;}
}
if (voltage <= 240 && voltage > 225)  { //SHUTTER PROFILE 11
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(18);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return ;}
}
if (voltage <= 1024 && voltage > 240)  { //SHUTTER PROFILE 12
    digitalWrite(15, HIGH);
    delay(15);
    if (digitalRead(2) == HIGH) {
    delay(16);
    digitalWrite(15, LOW);
    delay(50);
    digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
    delayMicroseconds(50);
    digitalWrite(7, LOW);
     return; }
   
}
  if (digitalRead(2) == HIGH)
  digitalWrite(7, HIGH);            //INDICATOR LED FOR FILM
  delayMicroseconds(50);
  digitalWrite(7, LOW);
}
if (digitalRead(2) == HIGH) {     //TURNS OFF LEDS IF SHUTTER ISN'T WOUND
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
}
  }

Thank you! Sorry i'm a noob to this forum so i was trying to figure out how to do a Code view, but couldn't figure it out.

At he top of every topic is a sticky called how to use this forum-please read that explains code tags and more.

Got it. this is my first time ever posting on a forum so i'm not used to how all of this works. Really just need help with this code though.

void loop() 
{
    while (digitalRead(2) == LOW) 
    {  //RUNS LOOP IF SHUTTER WOUND DURING HALF PRESS
        void loop();
.
.
.

What are you doing here? Calling a function from within a function is really bad form...

Haha I really don't know. I spent a week and just spammed code until i got it to work. The entire code works the way i want it to.

There's just inconsistency with the Switch going to ground reading properly.

I have it set with a Input_pullup and a 1k resistor in line.

This is mainly what i'm trying to figure out why i'm not getting 100% perfect readings on this.

I have it set with a Input_pullup and a 1k resistor in line.

Using INPUT_PULLUP as the pinMode() you don't need an external resistor. Exactly how is yours wired ?

I formatted your code a bit and added some pin names for easier reference. I found a couple of these:

        //DETECTS VOLTAGE REF FROM AREF
        int sensorValue = analogRead(A0);
        float voltage = sensorValue;
        if (voltage >= 80) 
        {
            analogWrite(pinLEDGreen, 180);  //GREEN LED ON IF VALUE MET
                               
        } 
        else 
        { 
            (voltage < 80); // <<<---- probably not what you intended
            {     //VCC IS CONNECTED TO ORANGE WIRE
                digitalWrite(pinLEDGreen, HIGH);
                              //GND GREEN WIRE CONNECTED TO (PIN 5)
            }                                   //PULLS HIGH TO TURN OFF LED
        }

I also notice a ton of repetition. The code should be cleaned up and matrices used with maybe a single function call for the shutter profiles.

I tried to just use the internal pullup but i would get more random misfires then with the resistor inline.

It’s just a spring that goes from the pin and makes contact with ground while the shutter is wound.

When the shutter is fired it releases the spring.

I know it’s always making good contact because the lights in the viewfinder come on just fine but there’s something to do with the way the code reads the release of the spring that’s not right.

I tried to do some debounce thing but it just broke all of my code and i couldn’t figure out how to get it to work.

Also i will look up matrices, I was hoping there was a better way to do the shutter profiles.

What does "resistor inlne" mean. In series between the switch and the input or from the input pin to V+ (pull-up) or from the input pin to ground (pull down)? Can you post a schematic of your wiring?

I don’t know how to post a schematic. I’m pretty new to all of this. My pcb is the one im using with this setup.

So by in line i guess i just mean in series. Pin 2 has the input_pullup set and then there’s a 1k resistor, then it goes straight to the pole that the Spring comes into contact with.

When the shutter is wound it pulls the pin low. When it is fired the spring releases and brings the pin back high.

When i adjust the spring i can get the error rate low, i.e a misfire every 18-20 shots. but i just want to figure out a way to make it 100% and not have to adjust the spring to make it work correctly.

The spring in question is the Gold one down towards the bottom left it connects to the green wire which goes up and connects directly to the 1k resistor then goes up to pin 2.

Next lesson, learning how to post pictures in line !

You’re correct,bounce house s probably your issue.
You need to test for the contact changing state, not when it is high or low.
Then (in this simple example) add a tiny delay(), say for 50mS after the switch has changed.
That should eliminate your problems, but in general, try to avoid delay() in more complex programs so they are more responsive.

Let us know how you get on.

The OP's image

I don't know how to post a schematic.

You could draw a schematic with pencil and paper, photograph it and post the photograph

Not sure I completely understand your “ground signal master” or its logic but here’s a re-imagining of what I think you’re trying to do. Compiles but untested.

#define NUM_PROFILES    12

//pin definitions
const byte pinGNDMaster = 2;        //GND SIGNAL MASTER  (PIN 2)(PWM)
const byte pinFlashReadyEN = 3;     //FLASH READY ENABLE (PIN 3)
const byte pinFlashGateOpen = 4;    //FLASH GATE OPEN    (PIN 4)
const byte pinGRNLed = 5;           //GREEN LED          (PIN 5)(PWM)
const byte pinREDLed = 6;           //RED LED            (PIN 6)(PWM)
const byte pinFILMLed = 7;          //FILM LED           (PIN 7)
const byte pinShutterCtl = 15;      //SHUTTER CONTROL    (PIN A1)
const byte pinPhotoResistor = A0;   //PHOTO RESISTOR

//prototypes
void ShutterFuncType1( unsigned long ExposureTime );
void ShutterFuncType2( unsigned long ExposureTime );

//define a pointer to a function that returns void and accepts an unsigned long
typedef void (*ShutterFunc)( unsigned long ExposureTime );

//shutter profiles - high range
const int nProfileRangeHigh[] = 
{
    60, 80, 100, 120, 135, 150, 165, 180, 200, 225, 240, 1023
};

//shutter profiles - low range
const int nProfileRangeLow[] = 
{
    0, 60, 80, 100, 120, 135, 150, 165, 180, 200, 225, 240
};

//shutter profile exposure times -- mS
const unsigned long ulExposureTimes[] = 
{
    50, 44, 40, 38, 36, 34, 32, 28, 24, 20, 18, 16
};

//an array of function pointers; each entry represents a profile # and the function that executes it
ShutterFunc ShutterProfileFunction[] = 
{
    &ShutterFuncType1,  //1
    &ShutterFuncType1,  //2
    &ShutterFuncType1,  //3
    &ShutterFuncType2,  //4
    &ShutterFuncType2,  //5
    &ShutterFuncType2,  //6
    &ShutterFuncType2,  //7
    &ShutterFuncType2,  //8
    &ShutterFuncType2,  //9
    &ShutterFuncType2,  //10
    &ShutterFuncType2,  //11
    &ShutterFuncType2   //12
    
};

void setup() 
{
    // PHOTORESISTOR CONNECTS TO VR RIGHT LEG
    // VR MIDDLE LEG CONNECTS TO AREF (PIN A0)
    // VR LEFT LEG CONNECTS TO GROUND
    //
    pinMode( pinGNDMaster, INPUT_PULLUP );        //GND SIGNAL MASTER  (PIN 2)(PWM)
    pinMode( pinFlashReadyEN, OUTPUT );           //FLASH READY ENABLE (PIN 3)
    pinMode( pinFlashGateOpen, OUTPUT );          //FLASH GATE OPEN    (PIN 4)
    pinMode( pinGRNLed, OUTPUT );                 //GREEN LED          (PIN 5)(PWM)
    pinMode( pinREDLed, OUTPUT );                 //RED LED            (PIN 6)(PWM)
    pinMode( pinFILMLed, OUTPUT );                //FILM LED           (PIN 7)
    pinMode( pinShutterCtl, OUTPUT );             //SHUTTER CONTROL    (PIN A1)
    digitalWrite( pinShutterCtl, HIGH );
    
}//setup                   

void loop() 
{
    static unsigned long
        timeMaster=0;
    unsigned long
        timeNow;
    static byte
        lastGNDMaster = 0xff;
    byte
        GNDMaster;

    //read GND master every 50mS
    timeNow = millis();
    if( timeNow - timeMaster < 50 )
        return;

    timeMaster = timeNow;
    
    GNDMaster = digitalRead( pinGNDMaster );
    if( GNDMaster != lastGNDMaster )
    {
        lastGNDMaster = GNDMaster;
        if( GNDMaster == LOW )
        {
            int sensorValue = analogRead( pinPhotoResistor );
            DriveRGLeds( sensorValue );            
            FindProfileIndex( sensorValue );
                        
        }//if
        else
        {
            //INDICATOR LED FOR FILM
            digitalWrite( pinFILMLed, HIGH );            
            delayMicroseconds(50);
            digitalWrite( pinFILMLed, LOW );
            
            //TURNS OFF LEDS IF SHUTTER ISN'T WOUND
            digitalWrite( pinGRNLed, HIGH );
            digitalWrite( pinREDLed, HIGH );
            
        }//else
        
    }//if
        
}//loop

/////////////////////////////////////////////////////////////////////////////////////////////
// ShutterFuncType1
//
/////////////////////////////////////////////////////////////////////////////////////////////
void ShutterFuncType1( unsigned long ExposureTime )
{
    digitalWrite( pinShutterCtl, HIGH );
    delay(15);
    if( digitalRead( pinGNDMaster ) == HIGH ) 
    {
        delay( ExposureTime );
        digitalWrite( pinShutterCtl, LOW );
        digitalWrite( pinFlashReadyEN, HIGH );
        digitalWrite( pinFlashReadyEN, LOW );
        delay(50);
        digitalWrite( pinFILMLed, HIGH );            //INDICATOR LED FOR FILM
        delayMicroseconds(50);
        digitalWrite( pinFILMLed, LOW );
        
    }//if

}//ShutterFuncType1

/////////////////////////////////////////////////////////////////////////////////////////////
// ShutterFuncType2
//
/////////////////////////////////////////////////////////////////////////////////////////////
void ShutterFuncType2( unsigned long ExposureTime )
{
        digitalWrite( pinShutterCtl, HIGH );
        delay(15);
        if( digitalRead( pinGNDMaster) == HIGH ) 
        {
            delay( ExposureTime );
            digitalWrite( pinShutterCtl, LOW );
            delay(50);
            digitalWrite( pinFILMLed, HIGH );            //INDICATOR LED FOR FILM
            delayMicroseconds(50);
            digitalWrite( pinFILMLed, LOW );
            
        }//if

}//ShutterFuncType2

/////////////////////////////////////////////////////////////////////////////////////////////
// DriveRGLeds
//
/////////////////////////////////////////////////////////////////////////////////////////////
void DriveRGLeds( int value )
{
    if( value >= 80 )
    {
        analogWrite( pinGRNLed, 180 );    //GREEN LED ON IF VALUE MET
        digitalWrite( pinREDLed, HIGH );
    }//if
    else
    {
        digitalWrite( pinGRNLed, HIGH );
        analogWrite( pinGRNLed, 180 );

    }//else
    
}//DriveRGLeds

/////////////////////////////////////////////////////////////////////////////////////////////
// FindProfileIndex
//
/////////////////////////////////////////////////////////////////////////////////////////////
void FindProfileIndex( int value )
{
    for( byte idx=0; idx<NUM_PROFILES; idx++ )
    {
        if( value >= nProfileRangeLow[idx] && value < nProfileRangeHigh[idx] )
        {
            ShutterProfileFunction[idx]( ulExposureTimes[idx] );            
            return;
            
        }//if
        
    }//for

}//FindProfileIndex

This is miles beyond anything i expected anybody to help me with. I will give this a try today and report back what i find. Thank you so much. Seriously!

Hi!, so i had a chance to test the code and it looks like all the camera does when the shutter button is pressed that the shutter just stays open until released.

The master ground control is suppose to be sort of like an activation switch.

When the Switch isn't making contact then the camera should do nothing. no lights come on or anything, When the shutter is wound the spring makes contact and is in an on state.

But its not so simple because i need the camera to complete it's task before going back to an off state. If that makes sense?

I appreciate all your help and understand if you're busy i'm really grateful for this massive amount of help. I can try and play with your code and see what i can do with my own.

I think I misinterpreted your code. Maybe this is closer:

#define NUM_PROFILES    12

//pin definitions
const byte pinGNDMaster = 2;        //GND SIGNAL MASTER  (PIN 2)(PWM)
const byte pinFlashReadyEN = 3;     //FLASH READY ENABLE (PIN 3)
const byte pinFlashGateOpen = 4;    //FLASH GATE OPEN    (PIN 4)
const byte pinGRNLed = 5;           //GREEN LED          (PIN 5)(PWM)
const byte pinREDLed = 6;           //RED LED            (PIN 6)(PWM)
const byte pinFILMLed = 7;          //FILM LED           (PIN 7)
const byte pinShutterCtl = 15;      //SHUTTER CONTROL    (PIN A1)
const byte pinPhotoResistor = A0;   //PHOTO RESISTOR

//prototypes
void ShutterFuncType1( unsigned long ExposureTime );
void ShutterFuncType2( unsigned long ExposureTime );

//define a pointer to a function that returns void and accepts an unsigned long
typedef void (*ShutterFunc)( unsigned long ExposureTime );

//shutter profiles - high range
const int nProfileRangeHigh[] =
{
    60, 80, 100, 120, 135, 150, 165, 180, 200, 225, 240, 1023
};

//shutter profiles - low range
const int nProfileRangeLow[] =
{
    0, 60, 80, 100, 120, 135, 150, 165, 180, 200, 225, 240
};

//shutter profile exposure times -- mS
const unsigned long ulExposureTimes[] =
{
    50, 44, 40, 38, 36, 34, 32, 28, 24, 20, 18, 16
};

//an array of function pointers; each entry represents a profile # and the function that executes it
ShutterFunc ShutterProfileFunction[] =
{
    &ShutterFuncType1,  //1
    &ShutterFuncType1,  //2
    &ShutterFuncType1,  //3
    &ShutterFuncType2,  //4
    &ShutterFuncType2,  //5
    &ShutterFuncType2,  //6
    &ShutterFuncType2,  //7
    &ShutterFuncType2,  //8
    &ShutterFuncType2,  //9
    &ShutterFuncType2,  //10
    &ShutterFuncType2,  //11
    &ShutterFuncType2   //12
   
};

void setup()
{
    // PHOTORESISTOR CONNECTS TO VR RIGHT LEG
    // VR MIDDLE LEG CONNECTS TO AREF (PIN A0)
    // VR LEFT LEG CONNECTS TO GROUND
    //
    pinMode( pinGNDMaster, INPUT_PULLUP );        //GND SIGNAL MASTER  (PIN 2)(PWM)
    pinMode( pinFlashReadyEN, OUTPUT );           //FLASH READY ENABLE (PIN 3)
    pinMode( pinFlashGateOpen, OUTPUT );          //FLASH GATE OPEN    (PIN 4)
    pinMode( pinGRNLed, OUTPUT );                 //GREEN LED          (PIN 5)(PWM)
    pinMode( pinREDLed, OUTPUT );                 //RED LED            (PIN 6)(PWM)
    pinMode( pinFILMLed, OUTPUT );                //FILM LED           (PIN 7)
    pinMode( pinShutterCtl, OUTPUT );             //SHUTTER CONTROL    (PIN A1)
    digitalWrite( pinShutterCtl, HIGH );
   
}//setup                   

void loop()
{
    static unsigned long
        timeMaster=0;
    unsigned long
        timeNow;
    static byte
        lastGNDMaster = 0xff;
    byte
        GNDMaster;

    //read GND master every 50mS
    timeNow = millis();
    if( timeNow - timeMaster < 50 )
        return;

    timeMaster = timeNow;
   
    GNDMaster = digitalRead( pinGNDMaster );
    if( GNDMaster != lastGNDMaster )
    {
        lastGNDMaster = GNDMaster;
        if( GNDMaster == LOW )
        {
            int sensorValue = analogRead( pinPhotoResistor );
            DriveRGLeds( sensorValue );           
            FindProfileIndex( sensorValue );
            
            //INDICATOR LED FOR FILM
            digitalWrite( pinFILMLed, HIGH );           
            delayMicroseconds(50);
            digitalWrite( pinFILMLed, LOW );
           
            //TURNS OFF LEDS IF SHUTTER ISN'T WOUND
            digitalWrite( pinGRNLed, HIGH );
            digitalWrite( pinREDLed, HIGH );
                       
        }//if
       
    }//if
       
}//loop

/////////////////////////////////////////////////////////////////////////////////////////////
// ShutterFuncType1
//
/////////////////////////////////////////////////////////////////////////////////////////////
void ShutterFuncType1( unsigned long ExposureTime )
{
    digitalWrite( pinShutterCtl, HIGH );
    delay( 15ul + ExposureTime );
    digitalWrite( pinShutterCtl, LOW );
    digitalWrite( pinFlashReadyEN, HIGH );
    digitalWrite( pinFlashReadyEN, LOW );
    delay(50);

}//ShutterFuncType1

/////////////////////////////////////////////////////////////////////////////////////////////
// ShutterFuncType2
//
/////////////////////////////////////////////////////////////////////////////////////////////
void ShutterFuncType2( unsigned long ExposureTime )
{
        digitalWrite( pinShutterCtl, HIGH );
        delay( 15 + ExposureTime );
        digitalWrite( pinShutterCtl, LOW );
        delay(50);

}//ShutterFuncType2

/////////////////////////////////////////////////////////////////////////////////////////////
// DriveRGLeds
//
/////////////////////////////////////////////////////////////////////////////////////////////
void DriveRGLeds( int value )
{
    if( value >= 80 )
    {
        analogWrite( pinGRNLed, 180 );    //GREEN LED ON IF VALUE MET
        digitalWrite( pinREDLed, HIGH );
    }//if
    else
    {
        digitalWrite( pinGRNLed, HIGH );
        analogWrite( pinGRNLed, 180 );

    }//else
   
}//DriveRGLeds

/////////////////////////////////////////////////////////////////////////////////////////////
// FindProfileIndex
//
/////////////////////////////////////////////////////////////////////////////////////////////
void FindProfileIndex( int value )
{
    for( byte idx=0; idx<NUM_PROFILES; idx++ )
    {
        if( value >= nProfileRangeLow[idx] && value < nProfileRangeHigh[idx] )
        {
            ShutterProfileFunction[idx]( ulExposureTimes[idx] );           
            return;
           
        }//if
       
    }//for

}//FindProfileIndex

I wish i wasn't such a useless sack and could understand exactly what's going on. So with this code it does a heap of things different.

The shutter does not actuate, the electromagnetic coil that holds the shutter open is only triggered while the camera is in the off state and does not power up when it is in the on state.

The leds in the viewfinders both come on briefly for about a second while camera is on state. While in the off state both the green and red leds stay on.

I do need some more proficient code like this though because in the future i plan on adding a manual shutter function with a dial that will allow the user to select their shutter speed or set it to automatic mode.

I also hope to add an i2c OLED display as well to output the information so it's viewable to the user.

I think you need to post a schematic, not just a photo of your setup. Details, not a ten-thousand foot view, are what's needed here.