I built the frame from what I had lying around. To hold the servo and breadboard, I glued down a few off-cuts of plywood.
For the arm, I used a 6″ piece of square dowel. I wrapped the photoresistor wires around it and secured them with tape.
I used jeweler’s wire to secure the arm to the servo — just loop the wire around and twist it tight.
Position a desk lamp so that it shines light towards the photosensor, from the other side of the hanging object.
Insert batteries into the battery holder and watch the fun. If the arm swings the wrong way, turn the servomotor around.
It might take some tweaking to find the “sweet” spot” where the light/sensor/ball all align to create the whacking action. But when you get it, it’s pretty funny to watch…
You can see the ball whacker in action here.