« Toys For Big Kids | Main | Knight Rider Switch »
I connected a piezo to the PWM pin (9) of the Arduino and then took the code from the "play melody" section of the arduino site. The problem with their code was that the only keys you could write sequences for would be C major and A minor because they only included variables for the white key notes. They supplied the note, the period (which is the space between wave cycles for a given note), and the hertz count, so I did simple calulations to find the median between whole tones to find out what the period would be for the semi-tones (C#, D#, F#, G#, and A#). I defined variables for the semi-tones and then I was able to write in whatever key I wanted, so I chose A major. I wrote a small loop that starts in A and arpeggiates each chord up to the dominant (A major, B minor, C# minor, D major, E major) then wrote a little quick phrase at the end to return to A. I then experimented with different types of sounds I could get out of the piezo by squeezing it or holding it up against a piece of metal to get a distorted square wave.
TrackBack URL for this entry:http://www.typepad.com/services/trackback/6a00d8341ff76553ef00d8350b3a4553ef
Listed below are links to weblogs that reference Arduino Piezo Sequencer:
The comments to this entry are closed.
Comments