I need help, in writing a code, which counts the button press (momentary) I do. The idea is that, if I press the button once, the LED on say pin 13 blinks continuously for 1000 miliseconds until I press it again,, in which case it blinks for 500 miliseconds, and so on. The idea is that I can control the output of a single pin by counting button presses,.
Please don't refer me to the counting button presses link on the playground (completely useless), but rater offer solutions, If someone could help me write the code, or even easier, just refer me to a good example of tutorial, (Except the one on the playground please).
Sounds like a job for a Finite State Machine to me.
Each time through the loop() function read the button pin.
Every time the button is pressed add one to a variable.
Use the value of the variable with switch/case.
Write the code that should be executed in each case, but don't use delay() as it stops anything happening but the delay, including reading the button. Instead, use millis() for timing as in the BlinkWithoutDelay example in the IDE.