Change impulse signal to the straight signal

First off you need to post the code that dosn't work.
Then you need to stop using a voltage regulator as a way of limiting the voltage pulses. That is a very bad idea because the regulator was not designed for that and you get all sorts of stability problems and responce time issues. A simple transistor will do what you want here.