Arduino controlling another arduino button

Hi,
i have two distinct arduinos, arduino A and arduino B.
Arduino B has a button that is 0v when open, 5v when i press (closed)
I am trying to controll the switch with arduino A, the same way as i did with my 808 spy cam a long time ago (Simulate push button with arduino - Project Guidance - Arduino Forum)
Connections are as shown below

Everything works fine (ie. when i press the button on arduino A, it press the button on arduino B) except one thing, that is happening but cant happen!
When Arduino A is starting, it makes the pin that is controlling the npn transistor (closing the button) go HIGH and then releasing... this only happens when the arduino is starting.
How can i prevent that ?

Code is basic...

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  digitalWrite(ledPin, LOW); 
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}

Just connect the output pin to the input pin. No need for transistors if the grounds are connected and the logic levels are the same. digitalWtite(HIGH) to 'press the button' and digitalWrite(LOW) to 'release the button'.

Thanks. But what if i wanted to do it this way ? What needed to be modified in order to prevent the arduino A to send High when it's starting ?

anyone ?

option 1: Consider "inverting" the LOGIC in your code. High or Low are what ever you want them to be... Active High or Active low is "your call" as long as you are keeping track of what each is being used for.

Option 2: Go direct Just like JohnWasser said... there is just no obvious reason for the extra circuitry here...

Option 3: if you insist on the transistors, consider that pins go into HI-Z mode at reset time... so consider Adding a 10K Pulldown resistor (to ground from the gate of the 2N7000) so it goes into a preferred "off" state on "no input" from Arduino. I am assuming that arduino B had internal pullups... if not...
consider it.

...and just for clarification, a 2N7000 is not an NPN nor would it be drawn as you have drawn.

Yeah, that image is old... it was a guy from here that drawn it for me , to be able to control the spy cam.
I will try the pull down resistor from gate to ground.

I'm just asking this way of doing it, so i know how to do it a near future when i need to control buttons from other ICs