On/off switch

I have a counter and I was wondering what operation can I do in order to write HIGH to a pin if the counter is even and LOW if the counter is odd.

Thanks

jucasan:
I have a counter and I was wondering what operation can I do in order to write HIGH to a pin if the counter is even and LOW if the counter is odd.

Thanks

Perhaps hold your breath. What have you tried?

Paul

//case of counter = 0 is ignored; some consider it even so you can modify to suit as you wish
if( counter != 0 )
{
    if( counter & 0x01 )
        //it is odd
    else
        //it is even

}//if

if( (counter % 2) == 0)
{
//conter is even
}
else
{
//counter is odd
}

I like Blackfin's answer, but treat 0 as even.

if ((counter & 0x01)==1){  // or 0x0001 if counter is an int
digitalWrite(yourPin, LOW);
}
else {
digitalWrite (yourPin, HIGH);
}

Thank you guys

Or:

digitalWrite(LEDPin, !(counter & 1));  // Even = HIGH/ON, Odd = LOW/OFF