Simple i/o sensor to detect contact/touch

I would use an IR beam for the cars to break. Or a reflective optical sensor under the track pointing up through a hole.