I think that you don't understand the nature of digital audio and the limitations of what you are trying to do, so here goes...
A perfect square wave is made up of an infinite number of frequencies, called the Fourier series. Here is a link to the wikipedia page. The math on that wiki page isn't important, but the pictures will show you what an imperfect square wave will look like and the text of that page is good. So even if your square wave is at 1 Hz, it has frequency content to well past 1 GHz (in a perfect world).
Digital audio and your sound card, has a limited frequency range. Most sound cards can do about 20 Hz to 20 KHz. Some sound cards will be more limited than that. There is no way that your sound card can output a perfect square wave-- and depending on the frequency of the square wave it is possible that what it spits out doesn't even closely resemble what you are trying to achieve.
This has nothing to do with "removing noise". The sound card is outputting what you want, to the best of its ability-- it is just leaving off the parts that it can't do. What remains just doesn't resemble a square wave very much. Remember that you have problems on both ends of the frequency range. The high frequencies are getting cut off, causing the ringing effects. But you are also going to square wave frequencies that are lower than what your sound card can do, which will cause lots of problems too.
I honestly don't know if you can make this approach work. @FakeName has proposed one method, which might work, or might not (not enough info to really know). You might also be able to modify that approach and come up with something else that works. In my opinion, you would be better off asking a different question. Rather than asking, "how do I remove the noise?" you should ask "how do I control my robot?". Of course you also need to get a lot more specific about the exact device that you want to control (make & model + web link) would be required.