Digital outputs firing on serial monitor opening, closing

I am wiring and testing a camera firing system, and it works fine. However, when I first put the 2.5mm stereo plug (hooked up to Arduino outputs with a 10k resistor in between) in to the camera, the shutter fires. Then, when I open the serial monitor to check out my timing, the shutter fires again. Again when I close the serial monitor. Any ideas on why this might be happening?

I posted in this forum because I'm not sure if this is hardware or software, and there is no general help forum.

It sounds like your code fires the shutter after reset (opening/closing the serial monitor will reset the Arduino) OR because the pins are configured as inputs on reset the hardware takes that as license to trigger the camera.

How do you have the circuit wired up?

the pins are outputs, I have that in void setup().

It’s wire up like this.
Pin 6 — 10k resistor — shutter
Pin 7 — 10k resistor — focus

I’ve tried it like this
Transistor
Pin 6 — |base |
Vcc — |collector|
|emitter | — 10k resistor — shutter (etc.)

Here’s the code that relates to the outputs.

void setup ()
{
 
  pinMode (shutter, OUTPUT);
  pinMode (wake, OUTPUT);

}

void loop ()
{  


 
  if (active == 1)
    { if (cameraState == 1 && currentMillis - previousMillis > SSR)
      { previousMillis = currentMillis;
      analogWrite (motorPin, 0);
      digitalWrite (wake, HIGH);
      cameraState = 2;
    //Serial.println("step1");
  }
 
     if (cameraState == 2 && currentMillis - previousMillis > 200)
      { previousMillis = currentMillis;
      digitalWrite (wake, LOW);
      cameraState = 3;
     //Serial.println("step2");
   }
  
    if (cameraState == 3 && currentMillis - previousMillis > 1300)
      { previousMillis = currentMillis;
      digitalWrite (shutter, HIGH);
      cameraState = 4;
   // Serial.println("step3");
      (shots = previousShots + 1);
    }
  
    if (cameraState == 4 && currentMillis - previousMillis > Exp)
      { previousMillis = currentMillis;
      digitalWrite (shutter, LOW);
      cameraState = 5;
    //Serial.println("step4");
      (previousShots = shots);}
  
    if (cameraState == 5 && currentMillis - previousMillis > 1900)
      { previousMillis = currentMillis;
        //if (motorVal/4 <65) analogWrite (motorPin, 0);
        //else 
        {analogWrite (motorPin, 128);}
      cameraState = 1;
    //Serial.println("step5");
  }
    }
    
    if (active == 1)
      {digitalWrite(ledPin, HIGH);}
    else
      {digitalWrite(ledPin, LOW);}
    
return;
}

don’t worry about all that other stuff. The sequence runs when active is 1. Active starts off as zero, but Shutter and Wake are already written as HIGH. I’ve tried having stuff like

if (active == 0)
{digitalWrite(shutter, LOW);
digitalWrite(wake, LOW);}

That didn’t help in the slightest.
Any ideas?

During a reset the pins are set to be inputs. Then your code sets them to be outputs. When they are inputs they float and do not drive your circuit, hence you are triggering on each reset. One way round this is to use a pull down resistor on the output you are using to prevent it from floating high.

I've tried it like this Transistor Pin 6 --- |base | Vcc --- |collector| |emitter | --- 10k resistor --- shutter (etc.)

Never connect the base of a transistor directly to an arduino pin always go through a resistor.

The issue where the shutter fires when the cable is inserted, isn't that just a shortcoming of TRS connectors?

don't think so. the reason I don't think it is is because when the Arduino pin isn't connected, the shutter doesn't fire as I insert it. And it doesn't happen with my other intervalometer

Turns out it was a problem with the way I was triggering the plug. Instead of sending voltage, the ideal way is to connect the plug's tip-ground/middle-ground.

I just plugged in a couple of transistors and it's working dandily. Thanks for all of your willingness to help