I'm using them to detect when a slot car passes a section of track. When the relay trips, it then closes a connection on a USB keyboard encoder to send a character 'e' (or any character) to a computer program to indicate that the car has just passed the section of track.

I put an LED in between the transistor and the relay so I have a visual indication that the circuit has activated.

However I'm finding that after about 5 passes, the circuit still works, but the USB encoder has frozen.

In looking carefully at the LED, I see it flicker as the car is going around the track. I can correlate the flickering with the car's movements as it goes over the seams in the track and the pickup-shoes on the car spark.

If I manually activate the circuit with my hand instead of the car running (hence no track-generated RF interference), the LED does NOT flicker at all and the USB encoder box never freezes.I can trip the circuit 300 times in a row and the computer records 300 trips successfully.

I suspect that RF interference is building up in the cable between the LDR and the circuit board.I put a longer cable on the LDR to locate the circuit further away from the track to see if that would reduce the interference.

It's working MUCH better, (I can get 50+ laps of the car before the USB port freezes) but is there an easy way I could modify the circuit to minimize the RF interference that is entering the circuit as a result of the sparking between the car's pickup shoes and the track as the car runs around the track?

Or if anyone has any ideas how I can keep the USB keyboard encoder from crashing that would be great too. FYI, I've used the keyboard encoder with push-buttons for 10+ years as a buzzer system for Quiz-Show type high school competitions. It never crashes from people pushing the buttons. It only crashes when the contacts in the relay in the circuit are connected to the encoder.

Hello imseakin.You can make a typical Faraday cage or shield the circuit inside a metallic and grounded box. But what i do suggest is to use a one-shot circuit to drive the USB. It may have for example a 150mSec pulse duration. I think this will solve your problem.