When I first bought the parts, I used to have problems, mostly noise that made the sensors switch "on" and "off" when the motors were running. This is an obvious problem and I solved it using 3 capacitors on each motor (4 total). Now I'm facing another problem. When the motors stall or are stressed (for example when I load them a bit more or stop it) the sensors switch to "on", reporting that an object is present. This is wrong and makes the robot go nuts (on the other hand it has some serious dance moves!).

The question is, should I apply more filtering (and where) or is this a battery issue? The motor controller is the classic L298, I will try and separate the motor power from the board/sensor power and report back. I really do not want a different supply, so what can I try? By the way, the sensor's LEDs (that show if they detect an object) seem to flicker when the motors are stalled. Should I try and change the PWM prescaler of the motors?

EDIT: I didn't post this to the sensor subforum because I think it more of a motor problem.

I tried powering the Arduino using a 9V battery and the motors using my robot's batteries and the problem was eliminated. The question remains though, how can I filter the remaining noise and use the same batteries?