Detecting varying PWM states

Thanks that would work but I was trying to avoid extra hardware as my project is already a bit cramped. Also I'm not quite sure how to design an RC filter that would give me clean enough analog output and I'm stuck having poll the signal still.