So I am trying to have an LED react to a button. The problem I seem to be having is how to add a delay in between the button click and the led reacting. Essentially I want to, for example, click the button 3 times and then 2 seconds later have the led flash 3 times or if I hold the button for a 3 seconds, for the last second of the hold the led will turn on for 3 seconds. What I have so far is:
//Global Vars
// Global Variables
int BUTTON = 2;
int LED = 12;
unsigned long DELAY = 2000;
void setup() {
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}
void loop() {
//Code that delays the button press
}
I don't know if I should try to store the times that the button is pressed in an array or do something else. Looking for suggestions/explantions and maybe even just some code and an explanation. Its just for fun/learning so I am more interested in knowing how to do it, not just having the code that will do it. Thanks!