how can I toggle 2 outputs with 1 input

I'm new to programing and i would like to toggle 2 output pins with one input pin to be able to turn on FETs to turn on relays in a H-Bridge to be able to move an actuator in and out with one input. I could only find a you tube video that a guy does it with LEDs but i could not find an example code. Here is a link to the video.

https://video.search.yahoo.com/search/video?p=how+to+toggle+2+leds+with+one+button+on+an+arduino&fr=yhs-invalid#id=1&vid=408724b749597378319afd7d4839e31d&action=view

Any help would be appreciated

Do you know how to determine the state of an input pin ?
Do you know how to set the state of an output pin ?

If no then look at the Digital examples in the IDE.

If yes then give the code a try and post it here for help.

Yes I used an example that I modified the output to pin 4 instead of 13 and was able to toggle the led on and off but had problems when I tried to add in the second output to pin 5

here is what i have tried and failed

int button = 2; // the number of the input pin
int redled = 4; // the number of the output pin
int grnled = 5;

int redstate = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
int grnstate = HIGH;
// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers

void setup()
{
pinMode(button, INPUT);
pinMode(redled, OUTPUT);
pinMode(grnled, OUTPUT);
}

void loop()
{
reading = digitalRead(button);

// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (redstate == HIGH)
if (grnstate == LOW)
redstate = LOW;
grnstate = HIGH;

else
redstate = HIGH;
grnstate = LOW;

time = millis();
}

digitalWrite(redled, redstate);
digitalWrite(grnled, grnstate);

previous = reading;
}

Note that I have reformatted the code below taken from your program.

      if (grnstate == LOW)
        redstate = LOW;
    grnstate = HIGH;

    else
      redstate = HIGH;
    grnstate = LOW;


    time = millis();

Which line(s) of code will be executed if grnstate is LOW ?
Which line(s) of code will be executed otherwise ?
Which line(s) of code will always be executed ?

How does the program know how many lines of code to execute after an if or an else ?

I’m sorry but I dont know if you are asking me questions or you’re telling me this is what the program is looking for. I’m an electronics tech but just started learning how to program.

Look at if..else in the learning>Reference part of the forum.

https://www.arduino.cc/en/Reference/Else

Pay attention to the correct use of curly braces.
Leo..

Mlocherjr:
I'm sorry but I dont know if you are asking me questions or you're telling me this is what the program is looking for. I'm an electronics tech but just started learning how to program.

I am asking questions to try and point you in the direction of possible problems with your program.

A straightforward question.
If grnstate is LOW which commands should be executed ?

Is it

redstate = LOW;

or

grnstate = HIGH;

or both of them ?