Hi,
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);
Serial.begin(9600);
}
void loop() {
digitalWrite(led_pin, HIGH);
delay(delay_value);
digitalWrite(led_pin, LOW);
delay(delay_value);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!
THanksS