Tags: 5V, Sound, Buzzer, Speaker, for, Arduino

Buzzer 5V Sound Speaker

  • 4.00 AED

    5.00 AED

    • Ex Tax:4.00 AED
    • Brands techmaze
    • Product Code: Digital
    • Availability: In Stock
    This 5V Electromagnetic Sound Generator is encapsulated in a Low Profile Housing Making it Particularly Suitable for Inclusion in Miniature Electronics Instrumentation. Positive Terminal is Marked. Supplied with PCB Pins for Direct Mounting to PCBs. Requires External Drive Circuit.Copy and paste cod..

    This 5V Electromagnetic Sound Generator is encapsulated in a Low Profile Housing Making it Particularly Suitable for Inclusion in Miniature Electronics Instrumentation. Positive Terminal is Marked. Supplied with PCB Pins for Direct Mounting to PCBs. Requires External Drive Circuit.


    Copy and paste code into Arduino IDE
    Note: if you want to play different pitches on multiple pins, you need to call noTone() on the pin playing before using tone() on the next pin
    Helpful Links: 
    -Arduino Code a Melody 
    -Sparkfun Piezo Experiment Guide
    -Arduino Tone() Info
    Example Code in Video:

    void setup() {
      pinMode(12, OUTPUT);
    }

    void loop() {
      tone(12, 261); //Middle C
      delay(1000);
      tone(12, 277); //C#
      delay(1000);
      tone(12, 294); //D
      delay(1000);
      tone(12, 311); //D#
      delay(1000);
      tone(12, 330); //E
      delay(1000);
      tone(12, 349); //F
      delay(1000);
      tone(12, 370); //F#
      delay(1000);
      tone(12, 392); //G
      delay(1000);
      tone(12, 415); //G#
      delay(1000);
      tone(12, 440); //A
      delay(1000);
      // put your main code here, to run repeatedly:
    }
    Fritzing Electrical Diagram:














    Harder but Efficient Code with For Loop:

    void setup() {
    pinMode(12, OUTPUT);
    }
    void loop() {
      int notes[10]={261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
      //            mid C  C#   D    D#   E    F    F#   G    G#   A
      for(int i = 0; i < 10; i++){
        tone(12, notes[i]); //accesses spots on the array.
        delay(1000);
      }
    }


    Tags: buzzer; sound; speakers