Author Options:

Is there a way to count button pushes on an arduino and have the led blink after pressed the button 4 time? Answered

i would like to make if the button pressed 4 time.. led will start blinking for 5 second and if button pressed 8 time.. led will start blinking for 10 second... Can anyone help me with an example code or a tutorial somewhere? Greatly Appreciated!


Yes use the Arduino debounce.

This works with Arduino UNO and MEGA.

If button pressed, increment counter

Wait until button isn't pressed.

If counter =4 blink led. then reset counter.

Check out the Tutorials and Reference sections of the Arduino website. You should be able to piece it together from there.

You can simply count the number of presses with a variable and when it reaches certain counts you can have it do whatever you need.

I can help with specific questions/issues but you should try and write as much of it yourself as you can.