Design and Programming help - 0-10VDC input with 0-5VDC output

Run the 0-10V thru 2 5K resistors:
10V
|

5K
<
|
| analog input pin, 0-5V input
|
5K
<
|
V Gnd

Then
analogInput = analogRead(analogPin); // reading will be 0 to 1023.

Divide the result by 4:
PWMoutput = analogInput>>2;

now result is in range 0 to 255
Invert it:
invertOutput = 255 - PWMoutput;

and send it out
analogWrite(PWMpin, invertOutput);

Put lowpass filter (resistor, capacitor) on PWM pin to smooth it out.