My design involves the use of touch sensors as user interface and uses the sensor input to tell the motor to let the ball pass. This is what we used at the top of our final sculpture as a gate to let the ball through when the user wants.
My initial design (shown to the right) has the touch sensor be hit by a ball, but in the real sculpture, we decided that the user will hit the touch sensor when they choose to drop the ball into the obstacle course. It was modified slightly to adapt to what we needed.
There were some challenges finding how long to make the motor wait as it rotated away. We wanted it to be a wide enough swing to let the ball pass, but also not too wide because then it could take too long for the motor to bring the stopper back and stop the other incoming balls. If it was too slow, it could let too many balls through and just mess up the user interface in general. So, we had to find a balance between the speed and the timing to make it just right and release one ball at a time into the obstacle course / pinball machine. Additionally, we struggled to suspend the obstacles and rotating platforms in our structure. We wanted them to freely rotate, but we also wanted them to be stable and not fall off of the structure. So, we put lots of supports on them to keep them in place, but this interfered with its path and made it unable to rotate. So, we had to make lots of adjustments when constructing the obstacles.
The code is structured in an "if, else" statement. If the sensor is touched, or if the sensor value is greater than zero, the motor will turn clockwise with 50% power, then return to the original position after waiting 1 second. In all other situations, the motor will not move at all and remain blocking the pathway. To visualize this, below is a flow chart:
Below on the top is my WM2D simulation, and the bottom is where we used it in our actual Mini-Sculpture.