I'll show this one using a clear motor.
Stand the motor so you can add a short axle on top.
Now you can attach a long beam through the holes along
the sides. Since we're making a door (or gate or...) I attached
the beam at one end so that it sticks out from the gear.
Next, find two small grey connectors...
I had to experiment quite a bit to get a program that worked
well. I wanted the door to open or close when I touched a
a larger image of the program.