thanks Mike for that great explanation, that code is almost what I wanted to do, can you tell me which values should I change to make the button works this way:
First push: LED is ON and stays ON until button push again
Second Push: LED blinks 1000ms and delays 1000ms (continue doing this until button is pushed again)
Third PUsh: LED blinks 2000ms and delays 1000ms (continue doing this until button is pushed again)
Fourth PUsh: LED blinks 3000ms and delays 1000ms (continue doing this until button is pushed again)
Fifth PUsh: the loop stops until button is pushed and the loop starts again
I suppose in this code part below are the values that we have to change to get what I want. Right?
void checkPush(){
int buttonNow = digitalRead(button);
if(buttonNow != pushState) { // something has changed
pushState = buttonNow; // this is the new state of the button to remember
if(buttonNow == LOW) { // button has gone from a not being pushed to pushed
flashState++; // increment the state variable
goTime = millis(); // make the change immediately
if(flashState > 2) { // wrap round the state variable
flashState = 0;
nextTime = 1000; // wrap round the speed
} else {
nextTime = nextTime / 2; // make flashing twice the speed
}
}
}
}
thanks, Mike , I still have lots to learn I am just starting with this great world of codes, really fascinating.