Operating an LED with a potentiometer

This is prob super easy, but as a noob, I'm stuck!

Here's what I want to do:

I want to map a potentiometer to an LED so that when the potmeter is at 0, the LED is at 0. When the potmeter is at 127, I want the LED to be at 1023. When the potmeter is at 255, I want the LED to have gone back down to 0.

I have read the articles on remap and multimap on the playground, but couldn' make any sense of them.

Hoping for swift replies as this is for a university project with a dead line fast approaching

Thanks!

below is the sketch I've written for controlling the LED, only it doesn't go back down to 0..

const int PotPin1 = 0;
const int LEDPin1 = 3;
int Pot1Value = 0;
int LED1Value = 0;

void setup() {

}

void loop() {
Pot1Value = analogRead(PotPin1);
LED1Value = map(Pot1Value, 0, 1023, 0, 120);
analogWrite(LEDPin1, LED1Value);
}

I want the LED to be at 1023. When the potmeter is at 255, I want the LED to have gone back down to 0.

I think you have analogRead and analogWrite ranges the wrong way around.
Have a look at the reference.
http://arduino.cc/en/Reference/AnalogRead

a dead line fast approaching

It's OK, the Rapture got called-off.

I think you have analogRead and analogWrite ranges the wrong way around.
Have a look at the reference.

Yeah, I know, I mixed up the ranges. Thanks.

But correcting that made no difference. I want to have it set up so the potmeter and LED correspond to each other like this:

potmeter: 0, 512, 1023
LED PWM: 0, 255, 0

Any ideas?

Thanks

Lots.
How about a range test.
If the pot is less than 512, then map one range, else map a different range.

Thanks! I made it work with two if conditions:D

I made it work with two if conditions

One "if" and an "else" should have done the trick.