state change detection - how to cancel the LED on when its on 0 count

ok this looks very simple but im struggling to get it right.

with the state change detection sketch the LED comes on and 0 count and then every 5th count of the push button but I want it to start with the LED off!!

so as im sure you know the sketch looks like this...

if (buttonPushCounter % 5 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

}

when i try and add anther condition such as...

if (buttonPushCounter !=0)

it does weird stuff like when the light comes on the 5th count it just stays on!! instead of switching off again.

I want to actually text me when it does the 5th count thats why its such an issue for me cos it texts me as soon as the arduino comes on!

It's hard to answer without seeing all the code, but my guess is that buttonPushCounter is set to 0 in your code, so the LED comes on for the first pass through the code. That's easy to fix with:

if (buttonPushCounter % 5 == 0 && buttonPushCounter != 0) {

That may fix it, but I'm just guessing. Make sure you read Nick Gammon's posts at the top of this Forum for posting code if you want to post your complete code here.

thanks a lot. i didnt know about the && function