pushbutton / delay problem


I am new to programming and have a small question. I hope someone can help me.
In order to learn how to use pushbuttons in order to change Values within the code I have set up a small test circuit.
If i press up the delay time increases, if i press down the delay time decreases and the LED is blinking accordingly.
Everything works the way it should, besides one thing. When the delay time is high, like 1000 the button doesnt respond very well and I have to keep on pushing for a whole loop.
Maybe someone can point me in the right direction on how to change my code in order to have an immediate respond when pushing the button.
Sorry for my bad english, I hope you can understand what I mean

Here is my code

int delay_value = 1000;
int led_pin = 6;
int button_pin_up = 9;
int button_pin_down=10;
void setup() {
pinMode(led_pin, OUTPUT); pinMode(button_pin_up, INPUT); (button_pin_down, INPUT);
void loop() {
digitalWrite(led_pin, HIGH);
digitalWrite(led_pin, LOW);

int button_state_up = digitalRead(button_pin_up);
if (button_state_up == HIGH)
{ delay_value = delay_value +100; }

int button_state_down = digitalRead(button_pin_down);
if (button_state_down == HIGH && delay_value > 100)
{ delay_value = delay_value -100; }

Serial.print (delay_value);
Serial.println (" ");


Any help is appreciated!

In the future, please post using code tags (the </> button) and not quote tags. Thanks for trying!

You are going to have these sorts of problems as long as you use delay(...). The power of your Arduino is wasted during the duration of the delay(...) function. One second (1000 milliseconds, delay(1000)) is a long time in the Arduino world.

You need to learn about state machines and the millis() function. I suggest you start by finding and studying the Blink Without Delay example.

See "Demonstration code for several things at the same time"

Thanks, will do!