Using logical operators This is a snip it of code from a program I am writing. I have the program turn an LED on and if a button is pressed when the LED is on I want it to add to a counter and print the counter value. The problem seems that my if statement is skipped. Right now the while loop is setup for 5 seconds using millis() and stays off using a short delay. This part (button_press_9())) is a function call to a Boolean I have setup for debouncing. If I put the function call in an if statement by its self for example to test it. It works and will turn an LED on and off. It seems the combination of the two is incompatible. 

Thank you in advance. 

unsigned long previousMillis = millis();
unsigned long currentMillis = millis();

while ((currentMillis - previousMillis) &lt; onTime)
{
    digitalWrite(ledPin4, HIGH);
    if (ledPin4 == HIGH &amp;&amp; (button_press_9()))
    {
        counter++;
        Serial.println(counter);
        currentMillis = onTime * 100;
    }
    currentMillis = millis();
}
digitalWrite(ledPin4, LOW);
delay(1000);
You should use 

if (digitalRead(ledPin4) == HIGH &amp;&amp; (button_press_9()))


instead of 

if (ledPin4 == HIGH &amp;&amp; (button_press_9()))