Button + Relay programming question

I've got a super cool butane flamethrower project! The gas is controlled by a solenoid valve and the ignition comes from an arc lighter. the solenoid and arc lighter are both connected to a 2 channel relay and are controlled by a momentary push button.

I am having difficulty programming the logic.

Requirements:
relay channel 1: activated when the button is pushed and deactivated when the button is released
relay channel 2: activated when the button is pushed and deactivated when the button is released BUT will deactivate itself if the button is held for more than 1 second

This is what i have so far it just allows the button to turn on/off both channels

Thanks for your help!


int button_pin = 3;

int relay_arc_pin = 7;
int relay_gas_pin = 11;

void setup() {

pinMode(button_pin, INPUT_PULLUP);

pinMode(relay_arc_pin, OUTPUT);
pinMode(relay_gas_pin, OUTPUT);

}

void loop() {

if(digitalRead(button_pin) != 0){
digitalWrite(relay_arc_pin, HIGH);
digitalWrite(relay_gas_pin, HIGH);
}
else{
digitalWrite(relay_arc_pin, LOW);
digitalWrite(relay_gas_pin, LOW);

}

}

Add another button (call it button2_pin). Use millis() to time the relay.

I don't see a relay channel 2 in your code. Which relay is relay channel 2? On your relays is activated HIGH or LOW?

Instead of:

if(digitalRead(button_pin) != 0)

I would recommend:

if(digitalRead(button_pin) == HIGH)

Also, please post your code using code tags. You can do that by hitting the </> button above the posting area.