Two arduinos, one switch.

Hey everyone,
I have two arduinos running on their own separate 9 volt batteries running the same code just providing different outputs, I need to use a switch to turn both of them on at the same time, this might seem like a simple question but I really don't want to mess up my circuit now as i'm so close to presenting at uni so i'm being extra careful, I have a switch with 6 pins that I was thinking of using, any help would be much appreciated.

many thanks

-Liam

liamrichards25:
I have a switch with 6 pins that I was thinking of using,
-Liam

not much info here but I am going to guess that this is a dpdt switch in witch case you can wire one side for each arduino power wire to do what you want.

.

Easiest way might be to use the switch to connect both resets to Gnd. When the switch opens, boards come out of their reset state and start running.
Or, use it to reset one, when it starts up have it send a signal to the other to start running.
The first can go into setup() and at then end pause a second then pull a pin low and start loop(); the second can go into its setup() and at the end start reading a pin that is pulled high via internal pullup, when it sees it go it goes to loop().

1st:

void setup(){
digital Write (startPin, HIGH);
pinMode (startPin, OUTPUT);
:
:
delay(1000);
digitalWrite (startPin, LOW);
}
void loop(){
:
:

2nd:

void setup(){
pinMode (startPin, INPUT_PULLUP);
:
:
while (digitalRead(startPin) == HIGH){
// hang out waiting for startPin to go LOW
}
// it went LOW, continue
}
void loop(){
:
: