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..