Hello, I am new to the arduino programming zone, i am working on a project and i am stuck somewhere. I will be using 2 pushbutton switches. When i press switch1 and then switch2 the LED must turn on and stay turned on. Can anyone help me with the coding ?
Much appreciated
Can anyone help me with the coding ?
What have you tried ?
Does it matter which button is pressed first ?
How are the pushbuttons wired ?
Do you have pullup or pulldown resistors in place to keep the inputs in a known state ?
Does the first pushbutton need to be held down whilst the second is pressed or can the first one be released before the second one is pressed ?
What, if anything, turns the LED off ?
I tried many many things but they were in vain. Yes i have wired pulldown resistors on the switch and the first pushbutton must be released when the second one is pressed. And it is supposed to be based on edge detection.
it is supposed to be based on edge detection.
OK, we are getting somewhere and know more about what you want to do, but not actually everything yet.
Look at the StateChangeDetection example in the IDE. It will show you how to detect when an input changes state, ie detect an edge.
With that principle in mind your code should do something like this
start of loop()
if button 1 becomes released
set boolean variable pressed1 to true
end if
if button 2 becomes released and pressed1 is true
turn on the LED
end if
end of loop()
Over to you to turn that into Arduino code
Hmmmm. You made me think about something. I'll try it and post if i get an answer