UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

Buzzer Class

Module: buzzer
  • ID: buzzer
  • Name: Buzzer
  • Category: sound
  • Manufacturer: seeed
  • Connection: pwm
  • Kit: gsk

This module defines the Buzzer interface for libbuzzer. This sensor can make different tones when connected to a pin capable of analog pulse-width modulation. It emits sound using a piezoelectric material that vibrates at different frequencies based on the input voltage.
buzzer.jpg

Methods

Buzzer

(
  • pinNumber
)
Number

Instantiates a Buzzer object.

Parameters:

  • pinNumber Number

    Buzzer pin number

Returns:

Number:

playSound

(
  • note
  • delay
)
Number

Plays a tone for a certain amount of time or indefinitely. When delay is not used, the sound can be stopped by calling stopSound() .

Parameters:

  • note Number

    Note to play (DO, RE, MI, etc.) or frequency

  • delay Number

    Time in microseconds for which to play the sound; if the value is 0, the sound is played indefinitely

Returns:

Number:

Note played

stopSound

()

Stops the sound currently playing. Should be called when playSound() does not have a delay value.

setVolume

(
  • vol
)

Sets the volume for the buzzer, but may affect the sound timbre. Works best with halved values; e.g., 1.0, 0.5, 0.25, etc.

Parameters:

  • vol Number

    Value to set the volume to, from 0.0 to 1.0

getVolume

() Number

Gets the buzzer volume.

Returns:

Number:

Value the volume was set to

name

() String

Returns the name of the sensor.

Returns:

String:

Name of the sensor