digitalWrite(LED_PIN, HIGH) turns LED off?

In my void loop() I have the following code (for a line-following robot):

    if (ReadBlack(2)){
      advance();
      Serial.println("CENTER Detected");
      digitalWrite(CENTER_GREEN_PIN, HIGH);
    } 
    else {
      Serial.println("NOT over the CENTER");
      digitalWrite(CENTER_GREEN_PIN, LOW);
    }

I know the ReadBlack() function is working correctly because of the debugging statements. But when the sensor is not over the black line, the led turns on, and the debugging statement indicates that I am not over the line. And conversely, when I am over the line, the LED turns off and the debugging statement indicates center detected. What could be wrong here?

Your LED is installed backwards of what you think it is?

I have double checked, and it is definitely in the right way. And that only makes sense because the digitalWrite(PIN, HIGH) send +5 volts. If the LED was in backwards, it would need to put out a minus five volts in order for the LED to come on. Or am I wrong about that?

The LED needs the anode to be high and the cathode to be low to turn on.
The high can be a digitalWrite High, and the low from Gnd.
Or, the anode can be High from +5, and the low from a digitalWrite Low.
(don't forget current limit resistors).

MrGibbage:
I have double checked, and it is definitely in the right way. And that only makes sense because the digitalWrite(PIN, HIGH) send +5 volts. If the LED was in backwards, it would need to put out a minus five volts in order for the LED to come on. Or am I wrong about that?

CrossRoads is right, but I thought I'd provide a schematic...

Either of the following will work, but the first one requires a HIGH on the Pin to turn the LED on, and the second requies a LOW to turn the LED on.

GND ------\/\/\-----|<|----- Pin

Pin ------\/\/\-----|<|----- +5V

Yep. That's exactly what I did. Rookie mistake. Thanks for the help!

hello there. I think I've made a mistake. I make the code digitalwrite(ledpin,high), but my led goes off. I have been convinced wiring correctly. So, what's going on my project? Pfft..
Thanks before..

I have been convinced wiring correctly

We can't see your code, we can't see your schematic.

Can you see the problem?

I make the code digitalwrite(ledpin,high)That code won't compile.

@Dindamaaya

Don’t highjack other peoples thread.

“I have been convinced wiring correctly. ”
Don’t trust the person who convinced you.

See the two LED configurations in the schematic below: