Thank you for the tip.
It's the delay(2000) that gives you problems.
Check the "blink without delay" sample code in the playground, it will show you how to fix your problem.
The Delay() function is blocking. This mean that for the 2000 ms duration of your delay, Arduino effectively does - nothing, so your button push won't be read until after the delay(s).
MikMo:
It's the delay(2000) that gives you problems.Check the "blink without delay" sample code in the playground, it will show you how to fix your problem.
The Delay() function is blocking. This mean that for the 2000 ms duration of your delay, Arduino effectively does - nothing, so your button push won't be read until after the delay(s).
I'm not sure where I would put the millis(); function or what else into my code to make it work.
Do you understand how blink without delay works?
AWOL:
Do you understand how blink without delay works?
No I do not.
get a sheet of paper and a pencil, and work through it until you do
gnozahs:
AWOL:
Do you understand how blink without delay works?No I do not.
Look in the examples under 2.Digital in the Arduino program.
cyclegadget:
gnozahs:
AWOL:
Do you understand how blink without delay works?No I do not.
Look in the examples under 2.Digital in the Arduino program.
Yeah, I've been looking at the examples such as the debounce and read some tutorials and writes up about debouncing push buttons and whatnot but I'm no C programming guru. I have no idea how I would integrate those coding seen in the examples into my code.
You will have to learn this. Look at the blink without delay example. Work through it, line by line, on a piece of paper with a pencil in hand, until you figure out how it works. Then you can apply that technique to your own problem.
In brief (to give you something to start with), the idea is to run through the "loop" function many, many times, and each time you run through, you check "is it time to change anything yet?" This means that you measure the amount of time since the last change, and only make a new change if that measurement is big enough.
This allows you to react to other changes in the loop function quickly -- for example, you can check your button each time through the loop, and given that the loop is run through every millisecond (for example), you'd react to a button press within a millisecond.