Green shaft tends to rotate clockwise thanks to a spiral spring located in the blue box (a weight and wire can be used instead of the spring).
Yellow cam controls 180 deg. interrupted rotation of the green shaft.
The spring that maintains the contact between the cam and pink slider is not shown.
Other driving source for the pink slider is possible, for example, a pneumatic cylinder.