I have this weird problem. I am busy implementing a raspberry Controlled Car. I am using the L298n to control the 2 DC motors. As a first interface I had created a JavaFx application running on my laptop. The JavaFX application communicated via RMI towards the car interface on the car. Yes I do everything in Java

I did a complete setup and configuration (first without car) to see if the ir sensor was working and it did. When I push a button on the remote control, my java application show in the terminal what button I pushed.
Next step was integrating this in the remote car. There I have this weird issue. The L298n has an external power source for the dc motor. When the batteries are inside and the wheels start spinning, the ir sensor is not reacting anymore. When without stopping my application, I pull out the batteries, the ir responds again. I have no clue what is going on.
Does anybody has any idea ? I tried to add a capacitor on the motors but without succes (although not sure I did this correct).
Any help would be welcome.
I am documenting my experiences on my blog. http://blog.byle.be
best regards,
Jan Byle