Adjust LED brightness with PWM

This small snippet of code uses an ultrasonic sensor to find the distance from an object. This distance is saved in Sensor1.

When it is below 25 cm, the LED should be bright. When it is below 70 cm and above 25cm, the LED should be dim, but not OFF.

Problem is it goes OFF between 25 and 70, rather than being dim. Suggestions?

#define ledpin A0

Sensor1 = distance;
if(Sensor1<25)
{analogWrite(ledpin,255);}

else if (Sensor1>25 && Sensor1<70)
{analogWrite(ledpin,175);}

else
{analogWrite(ledpin,0);}

Check here analogWrite() - Arduino Reference to see if the pin A0 you are using in your analogWrite() supports pwm. The other suggestion is to include your full code.

6v6gt:
Check here analogWrite() - Arduino Reference to see if the pin A0 you are using in your analogWrite() supports pwm.

Or just look at the board: there's no ~ printed next to the analog pins.