Code:

techdemo2

I used some of our technical lab code and adjusted the angle and speed to mimic a classic metronome.