Input: pink crank rotating counterclockwise.
Yellow plate is pivoted on violet slider.
Red pin (fixed to the plate) moves in U-shaped of the base.
The plate is 90 deg. flipped at the ends of the slider stroke.
When the slider moves forwards, the plate is parallel to the moving direction. When the slider moves backwards, the plate is perpendicular to the moving direction.
Inertia of blue weight (fixed to the plate) ensures that the flipping process is stable.