"Or" function?

Hey. For a project I am wondering how to do an "or." Allow me to explain:

Say I have 4 buttons, Button1, Button2, Button3, and Button4. And two led's, GreenLight, RedLight.

Button1 lights up GreenLight, and Button2 lights up RedLight. But here is what I want:

If I press Button1 it lights up GreenLight
If I press Button2 it lights up RedLight
If I press Button3 it ALSO lights up GreenLight
If I press Button4 it ALSO lights up RedLight.

Can this just be done with two "If" statements per light, and those If statements next to each other?

Look down under Boolean operators.

Think about it:

if Button1 or Button3 then Green
if Button2 or Button4 then Red

Now just supply the digital reads and you're there.

econjack:
Think about it:

if Button1 or Button3 then Green
if Button2 or Button4 then Red

Now just supply the digital reads and you're there.

So just two if statements per LED then?

Not sure why you need 4 buttons, but you could wire them externally in an "or" configuration (parallel) and save 2 inputs.

WesleyRTech:
Say I have 4 buttons, Button1, Button2, Button3, and Button4. And two led's, GreenLight, RedLight.

Button1 lights up GreenLight, and Button2 lights up RedLight. But here is what I want:

If I press Button1 it lights up GreenLight
If I press Button2 it lights up RedLight
If I press Button3 it ALSO lights up GreenLight
If I press Button4 it ALSO lights up RedLight.

Can this just be done with two "If" statements per light, and those If statements next to each other?

If you implement it in Automaton the syntax almost exactly follows your description.

#include <Automaton.h>

Atm_button button1, button2, button3, button4;
Atm_controller GreenLight, RedLight;
Appliance app;

void setup() {
  app.component( button1.begin( 2 ) );
  app.component( button2.begin( 3 ) );
  app.component( button3.begin( 4 ) );
  app.component( button4.begin( 5 ) );
  app.component( GreenLight.begin()
    .IF( button1 ).OR( button2 )
    .led( 10 )
  );    
  app.component( RedLight.begin()
    .IF( button3 ).OR( button4 )
    .led( 11 )
  );    
}

void loop() {
  app.run();
}

WesleyRTech:
So just two if statements per LED then?

He asked you to think about it.

aarg:
He asked you to think about it.

I am thinking. And that is what I came up with.