Skip to content

Buzzer Wireling Tutorial

buzzer product picture

This Wireling uses the AST7525MATRQ buzzer to give you the ability to add a variety of tones to your next project!

Technical Details

 AST7527MATRQ Specs

  • Oscillation frequency 2700Hz
  • Sounds pressure level 85 dB/min at 10cm

    TinyDuino Power Requirements

    • Voltage: 3.0V - 5.5V 
    • Current:  100mA (Max Rating).

    Pins Used

    • A5/SCL - I²C Serial Clock line
    • A4/SDA - I²C Serial Data line 

    Dimensions

    • 10mm x 10mm (.394 inches x .394 inches)
    • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 6.25mm (0.25inches)
    • Weight: 1 gram (.04 ounces)

    Materials

    To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

    There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

    Processor Adapter
    *TinyDuino and USB TinyShield Wireling Adapter TinyShield
    *TinyZero Wireling Adapter TinyShield
    *TinyScreen+ Wireling Adapter TinyShield
    WirelingZero N/A
    *RobotZero N/A
    Arduino Wireling Arduino Shield
    Raspberry Pi Wireling Pi Hat

    * These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

    In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

    You will also need the Buzzer Wireling and the included example Arduino sketch.

    Wireling Code
    Port 0

    Hardware Assembly

    Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch by editing the Analog pin used as noted in the program)

    NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

    Assembly of buzzer wireling and WirelingZero with cables


    Software Setup

    For this Wireling, you need the example Arduino program included above under the Materials section. Open up the program in the Arduino IDE. There should be a tones.h file included in this program, and you should see the tab for it in the Arduino IDE.

    Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.


    Upload Program

    After uploading the program, you should hear a short pattern of notes.

    Code
    /************************************************************************
     * TinyCircuits Buzzer Wireling Example
     * This program plays a little melody on the buzzer based on notes found 
     * in pitches.h.
     *
     * Based heavily on the Arduino toneMelody sketch found here: 
     * https://www.arduino.cc/en/Tutorial/toneMelody
     *
     * Hardware by: TinyCircuits
     * Written by: Zachary Lee for TinyCircuits
     * 
     * Initialized: 7/31/19 
     * Last updated: 12/04/19
     ************************************************************************/
    
    #include <Wireling.h> // Interface with Wirelings 
    #include "pitches.h"
    const int pin = A0; // A0 for port 0 on Wireling Adapter, A1 for port 1, etc
    
    // Notes in the melody:
    int melody[] = {
      NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
    };
    
    // Note durations: 4 = quarter note, 8 = eighth note, etc.:
    int noteDurations[] = {
      4, 8, 8, 4, 4, 4, 4, 4
    };
    
    void setup() {
      // Power & initialize Wireling
      Wireling.begin();
    
      // Iterate over the notes of the melody:
      for (int thisNote = 0; thisNote < 8; thisNote++) {
    
        // To calculate the note duration, take one second divided by the note type.
        // Ex. quarter note = 1000 / 4, eighth note = 1000/8, etc.
        int noteDuration = 1000 / noteDurations[thisNote];
        tone(pin, melody[thisNote], noteDuration);
    
        // To distinguish the notes, set a minimum time between them.
        // the note's duration + 30% seems to work well:
        int pauseBetweenNotes = noteDuration * 1.30;
        delay(pauseBetweenNotes);
        // Stop the tone playing:
        noTone(8);
      }
    }
    
    void loop() {
      // Put tones here if you want them to loop repeatedly
    }
    

    Notice that the pattern of notes will only play once. This is due to it being in the setup() loop. You can move the code into the loop() function if you want it to play repeatedly.


    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!