Electronic components that can pull a string around 5cm and then suddenly release it?
Pendulum motors were once popular for small animated retail displays. They had a permanent magnet as the pendulum weight and an electromagnet positioned to give the pendulum enough of a pull to keep it going. There was a simple switch mechanism that released the pendulum at the proper time. It should be possible to do something similar with a piece of iron rather than a permanent magnet, but a permanent magnet will likely be more effective. Search &quot;pendulum motor.&quot;
Using a permanent magnet has the added advantage of the possibility or using magnetic repulsion rather than or in addition to attraction.
This sort of mechanism is also used in &quot;gong&quot; and &quot;chime&quot; types of doorbells. The designs for those might also be useful to investigate.