How do I rotate a block 180 degrees after an item (like a car or train) passes a certain point in a track?
Here's an idea for converting the movement of a moving train to rotational motion track side. This is shown in set 6991:
The mechanism in this case is a tire hanging from a universal joint so that it engages the train without interfering too much:
This core idea could be mechanically adapted for other purposes, such as the 180 degree rotation that you are looking for.
If I understand the problem correctly, you have a track, on which something is moving in a straight line. Then you want to have another, stationary object to rotate when the moving something has passed a certain point on the track, right? Like a semaphore transitioning to another state after a train has passed a switchpoint?
If so, then the simplest solution would be to attach a piece of straight gear rack to the moving object and set up a gear by the tracks in a way so that the gear rack meshes with it as the object moves past. If the rack has exactly half the number of teeth as the gear, the gear will be rotated 180° upon their passing.
Possible combinations: 4566045: RACK W. BALL with 6 teeth:
and 4141454: DOUBLE CONICAL WHEEL Z12 1M with 12 teeth:
or: 374302: TOOTHED BAR M=1, Z=10 with 10 teeth:
and 4141455: DOUBLE CONICAL WHEEL Z20 1M with 20 teeth:
Due to the tight tolerances offered by these kind of teeth the alignment must be precisely calibrated and the passing speed should not be too high (especially if the rotational resistance or inertia is high) - in such cases knob or splat gears could provide better characteristics.
Or for very high speed applications the gear rack could be replaced with a long slope, which engages a single protruding piece and rotates it a bit by a horizontal axle while passing by. The resulting motion can then be amplified through adequate gearing to give 180° at the desired point and incorporate a ratchet to prevent returning after the slope has passed.