Simulating a transmissive photo interrupter sensor with Arduino
Basically, you need to pick a filter with a cutoff frequency lower than your source frequency in order to get the PWM to look like DC. To be clear, no first-order filter (or any filter) will turn a signal into pure DC (there will always be a noise component), but you can get close enough that your receiving circuitry won't care. 

In order to calculate cutoff frequency, we utilize this formula, which is for first-order RC filters:

\$f_c = \dfrac{1}{2\pi R C}\$

Now we must use a little bit of engineers' intuition to figure out what would be an appropriate cutoff frequency. I would say start at a cutoff frequency of 10hz and go from there. Through a simple re-arrangement of the formula, we can calculate \$R\$ by selecting \$f_c\$ and \$C\$. 

\$R = \dfrac{1}{2\pi f_c C}\$

The reason I chose to "select" the value of the capacitor is because usually it's a lot easier to find an appropriate resistor (or resistor network) than it is to find an odd sized capacitor. So if you have a bunch of capacitors laying around, pick one and go from there. If your resistance is really wacky (like really high or really low), pick a new C and try again. For this situation, you could get away with using a 10uF cap and a 1.5K resistor.

If you find that there is too much ripple, increase the value of your capacitor. If you find that you need faster response to changing PWM frequencies, lower the value of your capacitor. You can accomplish similar effects by changing the value of R, but that will limit your drive capability on that pin as R gets higher and higher. Additionally, if the value of R approaches the input impedance of the load you are driving, it will begin to act like a voltage divider which is not desirable. 

There are also many filter calculators on the internet that can help you design this thing. Usually for this type of situation you do not need to apply a whole lot of engineering rigor; if you can estimate what you need, and that works for you, then there really isn't a need to do any deeper analysis.