the circuit thing is very doable on the cheap but hard to explain, so I'm going to offer another largely mechanical solution
(aka crankshaft)
This needs some clearance, but you get the idea, might be able to put the motor ON the light and regain some clearance on the right. Need a solid rod connecting the arm to the light here. Might also adapt a scissors/extender thingy somehow and not need additional side clearance.