# Adding 2 buttons for increase or decrease value in for loop

**URL:** <https://forum.arduino.cc/t/adding-2-buttons-for-increase-or-decrease-value-in-for-loop/1130992>\
**Category:** Programming\
**Created:** [May 25, 2023, 4:08pm UTC](https://forum.arduino.cc/t/adding-2-buttons-for-increase-or-decrease-value-in-for-loop/1130992 "2023-05-25T16:08:01Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![build\_1971](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/build_1971/32/689930_2.png) [@build\_1971](https://forum.arduino.cc/u/build_1971)\
**Post date:** [May 26, 2023, 4:57am UTC](https://forum.arduino.cc/t/adding-2-buttons-for-increase-or-decrease-value-in-for-loop/1130992/5 "2023-05-26T04:57:07Z")

</div>

You need to make your code non blocking (see examples of non blocking code or blink without delay).  
You need to replace delay with timers. Once you have done that you can simply add a button to a digital input and monitor that.  
Forget about the interrupts suggested above. That will solve your current problem, but not the next...  
Interrupts are for things that cannot wait (tachometers in motors).

[https://forum.arduino.cc/t/flashing-multiple-leds-at-the-same-time/1065564/8](https://forum.arduino.cc/t/flashing-multiple-leds-at-the-same-time/1065564/8)

> [@Using millis() for timing. A beginners guide](https://forum.arduino.cc/t/using-millis-for-timing-a-beginners-guide/483573):
>
> Part 1 It is not usually long before new Arduino users discover that although the delay() function is easy to use it has side effects, the main one of which is that its stops all activity on the Arduino until the delay is finished (not quite true, I know, but that is usually how the problem presents itself). When this occurs the new user is usually directed to the BlinkWithoutDelay example sketch (BWoD) and/or the excellent thread entitled Several things at the same time. [Several things at the…](http://forum.arduino.cc/index.php?topic=223286.0)

---

_[View the full topic](https://forum.arduino.cc/t/adding-2-buttons-for-increase-or-decrease-value-in-for-loop/1130992)._
