I seem to have it working...although my code isn't to nice.
Was really thinking and trying to incorporate some kind of counting system each time the main momentary switch is pressed.
I noticed sometimes it likes to skip the shut down part of the code and go to the power on section.
Old sketch..NOT using:
// Turning on electrical systems in my Arcade Cabinet with Seeed relay module.
// When powering up, this is the order of the relays:
// AC power remote relay, TV remote relay and finally the computer relay.
// When shutting down, it's reversed:
// Computer relay (10 sec. for complete shutdown).
// Then AC power remote relay.
// The arduino in this setup will be powered by a 9V battery.
// 12Sep14
int switchState = LOW;
const int relayPin1 = 7; //Digital pin to control the relay for the AC power (remote AC outlet) 'relay #1'.
const int relayPin2 = 6; //Digital pin to control the relay for the TV (remote) 'relay #2'.
const int relayPin3 = 5; //Digital pin to control the relay for the Computer 'relay #3'.
const int mainSwitch = 9; //Digital pin input to control relays 1-3.
long previousMillis = 0; // will store last time switch was pressed
long countPresses = 0; // interval (milliseconds)
void setup()
{
Serial.begin(9600);
pinMode(mainSwitch, INPUT);
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
pinMode(relayPin3, OUTPUT);
digitalWrite(mainSwitch, HIGH);
}
void loop()
{
if(digitalRead(mainSwitch) == LOW) // main button is pressed
{
delay(3000); //Wait a few seconds after pushing the main Cabinet switch.
//First turn on electrical system (Will remain on until the end or no more movement).
digitalWrite(relayPin1,HIGH);
delay(300);
//Turn off relay for AC power (remote cntrl.).
digitalWrite(relayPin1,LOW);
delay(5000);
//Turn on relay for TV (remote cntrl.).
digitalWrite(relayPin2,HIGH); //Turns on TV.
delay(300);
//Turn off relay for TV.
digitalWrite(relayPin2,LOW);
delay(3000);
//Turn on relay for PC.
digitalWrite(relayPin3,HIGH); //Turns on PC.
delay(300);
//Turn off relay for PC.
digitalWrite(relayPin3,LOW);
delay(10000);
}
// Now Shutting down the entire Arcade Cabinet.
// Relays are reversed and we only need PC relay and then the AC power relay.
if(digitalRead(mainSwitch) == LOW) // main button is pressed.
{
digitalWrite(relayPin3,HIGH);
delay(300);
//Turn off relay for PC.
digitalWrite(relayPin3,LOW);
delay(10000);
digitalWrite(relayPin1,HIGH);
delay(300);
//Turn off relay for Elect Sys.
digitalWrite(relayPin1,LOW);
delay(5000);
}
countPresses + 2;
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > countPresses)
{
// save the last time you pressed the switch
previousMillis = currentMillis;
}
}

