From “Peri Automatopoietikes” (On the making of Automata) by Hero from Alexandria (around the year 50 AD) in the edition by Schmidt from 1899.
In this book he describes a kind of automatical theatre, showing different scenes from a mythical story. One of the (many !) control mechanisms he describes is the above: a cord is wound in a pattern around pegs on a shaft, so that when the cord is pulled with a constant speed (he describes very ingenious systems for that too), the shaft will perform a programmed sequence of half-turns and pauses.