First, do you have a resistor in series with the LED?
I connected an led anode to 5v and cathode to gpio 7
When the Arduino output pin goes low, current flows from positive to negative through the LED and it lights up. With an LED wired that way, PWM is reversed with 255 being off and zero being full-brightness.
(non-pwm) and found that gpio 7 can have a highest value of 127 out of 255
That sounds like PWM. What Arduino are you using?
If you write anything other than a zero to a digital (non PWM) pin you'll get a HIGH (about 5V). I don't know what happens with analogWrite() to a non-PWM pin.
which translates to 2.49 volts.
The Arduino doesn't have true-analog outputs. The output pins are either zero or +5V. [u]PWM[/u] switches quickly between zero and 5V. That can make an LED appear dim or it can control the speed of a motor. A multi-meter might read something close to the average but you can't count on that.
Or, that could be the voltage across the LED with another 2.5V across the resistor.
Or, if you don't have a resistor you may be drawing excess current and "pulling down" (or "pulling up") the Arduino's output voltage. I that case it could be putting 2.49V and that would be a bad thing!
I expected that if I changed the 5v to 3.3v the led wouldn't light up (because of the lower voltage difference), but the led lit up as well.
Most LEDs have a forward operating voltage of about 2V (depending on color, etc.). But, you need a little extra to "drop" across the resistor so you can control the current.
I can go as high as 254 and still have some light output. How does that work?
8-bit PWM goes from zero to 255. With the LED wired "backwards", PWM works "backwards" and 254 is equivalent to "1" and the LED may glow dimly. (Actually it's "flashing" very briefly at full brightness but since it's mostly off, our eyes see it as dim.)