How to generate button pressed Delay

hello sir/maa'm

after a long time i post something to learn about.

i want to do blinking led with some interesting concept
I just need delay at specific time i mean if i used one button and one led for blinking and if i pressed button for 500 millisecond than delay of blinking led will be set for 500 millisecond and if pressed for 200 ms than it will be 200 ms and so on...
if any one guide me proper way than i much understand better programming logic...
thanks in advance... :slight_smile:

Do you need to change the blink rate at any time, or is it good enough to set the blink rate once at the beginning and if you need to change the blink rate later, you can press reset and set a new blink rate?

If you need to change the blink rate at any time, then you cannot use delay() for more than about 100ms.

So as PaulRB points out, your specification is incomplete, so you need to have a full specification before you proceed. :astonished:

What is the "delay of blinking LED"? Is it the time it is on, the time it is off, or the time between the start of one blink and the start of the next? What exactly are the desired times?

Many years ago (in the days of the PIC) I conceived of the notion of a metronome whose rate you set by tapping a single button - and which would then indicate on a display the actual beats per minute. Similarly, a pre-digital project in Electronics Australia magazine featured a windscreen wiper controller based on two buttons which determined its interval by the interval between two presses of the "+" button. I am quite surprised that such a design has not been incorporated into production cars. :grinning:

Make a timer - not with delay() - which is reset when inactive and runs when a button is pressed. When the button becomes
unpressed store the accumulated value of the timer as your blink value.

Further reading/study, first five of IDE -> file/examples/digital.

Get the timer to behave first before adding more features.

dougp:
Make a timer - not with delay() - which is reset when inactive and runs when a button is pressed. When the button becomes
unpressed store the accumulated value of the timer as your blink value.

Further reading/study, first five of IDE -> file/examples/digital.

Get the timer to behave first before adding more features.

hello sir

I appreciate your advice that will helps me but i done it with timer and millis() that gave two values for pressed and release time and after that we can set led blinking rates with it without delay

i done that with millis() and blinking without delay idea...

thank you for your advise.