The buzzer can be used to generate tones between 31Hz and 65536 Hz.

Grove buzzer

Hardware

This buzzer can be used to emit notes at a particular frequency. It is connected to Arduino digital port D5 in the Grove Beginner Kit for Arduino.

Software

Functions that interact with the buzzer are prefixed with buzzer.

You can play a single sustaining note duration with buzzer_frequency:

def buzzer_frequency(pin, freq):
    """Play note of given frequency

    Parameters:
        pin (int):       Digital connection port (range: [2, 8])
        freq (int):      Frequency of note in Hz
    """

You can play a single note of a specific duration with buzzer_note:

def buzzer_note(pin, freq, duration):
    """Play note of given frequency

    Parameters:
        pin (int):       Digital connection port (range: [2, 8])
        freq (int):      Frequency of note in Hz
        duration (float):  Note length in seconds
    """

If your buzzer gets stuck playing a note, you can stop it with buzzer_stop:

def buzzer_stop(pin):
    """Stop note

    Parameters:
        pin (int):       Digital connection port (range: [2, 8])
    """