Multi Pattern Blink LED using 2 momentary switches.

Hi all,

I have a project where I need to control a series of high power LEDs using 2 switches. For the purpose of a prototype I have a single LED connected to pin 13 via a 1kohm resistor to simulate the high power LEDs.

Momentary switches are connected to pins 2 & 3.

I need to create code to do the following:

When SW1 is pressed (SW2 not pressed), code runs LED flash pattern on loop until SW2 is pressed.

When SW2 is pressed (SW1 not pressed), code switches LED off.

I need it so the switches do not need to be held down, just a single press.

I have managed to create flash patterns and control these using switches individually but cannot get the above to work.

Any help would be hugely appreciated!

Post your code. Read the how to use this forum sticky to see how to properly post code and some advice on how to get the most from the forum.

Describe what your code actually does so that we know what "cannot get the above to work" means.

Agree with @groundFungus.

That said, you could probably do this with one button.

Create flashing function.
Create button read function with software debounce.
Use button read function to switch LEDPatternState variable from state A to state B.
Call flashing function if in state B.