This is an old revision of the document!
This a connected circuit of a joystick, Servo Motor and passive buzzer. The Servo and buzzer are both controlled by the joystick. So, if the joystick is moved down to the left (where Y is at its max and X is at its minimum) the servo will increase in angle until its maximum of 180 degrees which will then set off the buzzer if the joystick is continually held in this position. Then the opposite is true for when the joystick is moved to the top right (when X is max and Y is minimum). So, the servo instead decreases in angle and then the buzzer will be triggered if the joystick is held over to that section continually.
Passive Buzzer Music Player Wire up two or more buttons in addition to the passive buzzer. Create a playTone function with arguments for frequency in hertz and duration in milliseconds. Initialize variables with the names of musical notes in different octaves. FOr example:
int C4 = 261; int Cs4 = 277; // C#4 / Db4 int Db4 = 277; // Db4 int D4 = 293; int Ds4 = 311; // D#4 / Eb4
which corresponds to the C and D notes of the 4th musical octave, including all their sharp and flat variations. Create 2 arrays, one of which will include the notes of a musical piece, and the other will contain the duration of the musical notes. In 4:4 time signature, I set a quarter note at 250ms. a half note as 500ms, etc. Then I called the playTone functions with the arrays as the arguments, and told the pi to begin playing the function when the button is pressed. For the sake of simplicity, I also initialized variables for note duration, with Q as a quarter note, H has a half note, etc.