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.
This connected circuit contains a joystick, a active buzzer and a LED. The whole thing is ran by the joystick moving in the y direction. The joystick is a two axis analog device that allows for directional movement and a button press feature. When the joystick is moved in the Y direction, the active buzzer and LED light are both turned on but only as long as the joystick is being pushed/held in the y direction. The LED light is a simple output device that produces light when a electric current flows through it. While the active buzzer is a component that emits a sound when powered. unlike a passive buzzer, an active buzzer has an internal oscillator that makes it easier to control, meaning when a voltage is there it will generate sound. The goal and inspiration for this project was a hockey goal buzzer and light.