Clockworks are often powered by a clockwork motor consisting of a mainspring, a spiral torsion spring of metal ribbon. Energy is stored in the mainspring manually by winding it up, turning a key attached to a ratchet which twists the mainspring tighter. Then the force of the mainspring turns the clockwork's gears, until the stored energy is used up. The adjectives wind-up and spring-powered refer to mainspring-powered clockwork devices, which include clocks and watches, kitchen timers, music boxes, and wind-up toys.
The earliest known example of a clockwork mechanism is the Antikythera mechanism, a first-century BC geared analogue computer, somewhat astrolabe-like, for calculating astronomical positions and eclipses, recovered from a Greek shipwreck. There are many other accounts of clockwork devices in ancient Greece, even in its mythology, and the mechanism itself is sophisticated enough to indicate a significant history of lesser devices leading up to its creation.
At some point, this level of sophistication in clockwork technology was lost or forgotten in Europe, and only returned when brought from the Islamic world after the Crusades, along with other knowledge leading to the Renaissance. Clockwork finally recovered the equivalent of pre-Roman technological levels in the 14th century.
As in Greek mythology, there are ambitious automation claims in the legends of other cultures. For example, in Jewish legend, Solomon used his wisdom to design a throne with mechanical animals which hailed him as king when he ascended it; upon sitting down an eagle would place a crown upon his head, and a dove would bring him a Torah scroll. It's also said that when King Solomon stepped upon the throne, a mechanism was set in motion. As soon as he stepped upon the first step, a golden ox and a golden lion each stretched out one foot to support him and help him rise to the next step. On each side, the animals helped the King up until he was comfortably seated upon the throne.
In ancient China, a curious account of automation is found in the Lie Zi text, written in the 3rd century BC. Within it there is a description of a much earlier encounter between King Mu of Zhou (1023-957 BC) and a mechanical engineer known as Yan Shi, an 'artificer'. The latter proudly presented the king with a life-size, human-shaped figure of his mechanical handiwork (Wade-Giles spelling):
The king stared at the figure in astonishment. It walked with rapid strides, moving its head up and down, so that anyone would have taken it for a live human being. The artificer touched its chin, and it began singing, perfectly in tune. He touched its hand, and it began posturing, keeping perfect time...As the performance was drawing to an end, the robot winked its eye and made advances to the ladies in attendance, whereupon the king became incensed and would have had Yen Shih [Yan Shi] executed on the spot had not the latter, in mortal fear, instantly taken the robot to pieces to let him see what it really was. And, indeed, it turned out to be only a construction of leather, wood, glue and lacquer, variously coloured white, black, red and blue. Examining it closely, the king found all the internal organs complete—liver, gall, heart, lungs, spleen, kidneys, stomach and intestines; and over these again, muscles, bones and limbs with their joints, skin, teeth and hair, all of them artificial...The king tried the effect of taking away the heart, and found that the mouth could no longer speak; he took away the liver and the eyes could no longer see; he took away the kidneys and the legs lost their power of locomotion. The king was delighted.
Other notable examples include Archytas's dove, mentioned by Aulus Gellius. Similar Chinese accounts of flying automata are written of the 5th century BC Mohist philosopher Mozi and his contemporary Lu Ban, who made artificial wooden birds (ma yuan) that could successfully fly, according to the Han Fei Zi and other texts.
By the 11th century, clockwork was used for both timepieces and to track astronomical events, in Europe. The clocks did not keep time very accurately by modern standards, but the astronomical devices were carefully used to predict the positions of planets and other movement. The same timeline seems to apply in Europe, where mechanical escapements were used in clocks by that time.
Up to the 15th century, clockwork was driven by water, weights, or other roundabout, relatively primitive means, but in 1430 a clock was presented to Philip the Good, Duke of Burgundy, that was driven by a spring. This became a standard technology along with weight-driven movements. In the mid-16th century, Christiaan Huygens took an idea from Galileo Galilei and developed it into the first modern pendulum mechanism. However, whereas the spring or the weight provided the motive power, the pendulum merely controlled the rate of release of that power via some escape mechanism (an escapement) at a regulated rate.
The Smithsonian Institution has in its collection a clockwork monk, about 15 in (380 mm) high, possibly dating as early as 1560. The monk is driven by a key-wound spring and walks the path of a square, striking his chest with his right arm, while raising and lowering a small wooden cross and rosary in his left hand, turning and nodding his head, rolling his eyes, and mouthing silent obsequies. From time to time, he brings the cross to his lips and kisses it. It is believed that the monk was manufactured by Juanelo Turriano, mechanician to the Holy Roman Emperor Charles V.
Often power for the device is stored within it, via a winding device that applies mechanical stress to an energy-storage mechanism such as a mainspring, thus involving some form of escapement; in other cases, hand power may be utilized. The use of wheels, whether linked by friction or gear teeth, to redirect motion or gain speed or torque, is typical; many clockworks have been constructed primarily to serve as visible or implicit tours de force of mechanical ingenuity in this area. Sometimes clocks and timing mechanisms are used to set off explosives, timers, alarms and many other devices.
The most common examples are mechanical clocks and watches. Others include: