Islamic scholar Al-Jazari(1150-1220) lived in what was northern Mesopotamia _today's northeastern Syria and Iraq.The cam and camshaft were invented by Al-Jazari in 1206 and were part of his 'castle clock' - a complex water-powered astronomical clock.
The castle clock invented by al-Jazari (1136 – 1206) is one of his many inventions mentioned in his book 'Kitáb fí ma'rifat al-hiyal al-handasiyya' (Book of Knowledge of Ingenious Mechanical Devices). One component of this clock was a set of robotic musicians that automatically played music when moved by levers. The levers were operated by a camshaft that was attached to a waterwheel. The musicians only played on the sixth, ninth and twelfth hour. The cams were configured so that the musicians played in unison.
Al-Jazari, who employed them in his automata,water clocks (such as the candle clock) and water-raising machines.The cam and camshaft later appeared in European mechanisms from the 14th century.