Two-button code with LED

Hey,
I need some help with a school task.
I have 2 buttons. Button one shall be pressed first, then the second one and the LED should light up.

If you do it the other way, press button 2 first, then the first one, a red LED should light up.

Any ideas of how I can do this? :slight_smile:

Any ideas of how I can do this?

Yes I have, but it is your homework, not mine.

Do you know how to read an input from a pushbutton ?
Do you know how to test the value of an variable and do something if it has the value you tested for ?
Do you know how to turn on an LED ?

If the answer to all 3 is yes then you have enough knowledge to complete the task. If not then it is time to look at the Arduino examples and understand what they do and how.

Yes I know all of that, but I don't get how I am going to make it light up using the buttons in the right order.

I was going to say much the same as UKHB.

There's two things unclear to me...

First, does the first button to be pressed get released before the second one is pressed or does it stay pressed while waiting and while the other is pressed? This is fundamental to how the coding will go.

Second, when you say an LED must light up, do you mean:

  • light up and stay on?- in which case does it need to be turned off again?- if so, when?
  • light up and stay on while the button's pressed

osteper:
Yes I know all of that, but I don't get how I am going to make it light up using the buttons in the right order.

Well that's where you need to apply your mind.

Do you do maths at school? Think of a geometry problem. You know all the theorems and laws, and how to bisect angles and shit, but you need to use that knowledge to solve the problem. The answer to geometry problems is seldom immediately apparent; you need to think about it.

How would YOU determine the order if you were slapped upside the left side of the head first, and then the right side? You'd be interested in knowing when each thing happened, right? Maybe millis() would be useful.