Show:
Extends webduino.Module

The Buzzer Class.

Constructor

webduino.module.Buzzer
(
  • board
  • pin
)

Parameters:

  • board webduino.Board

    The board that the buzzer is attached to.

  • pin Integer

    The pin that the buzzer is connected to.

Methods

addListener
(
  • type
  • listener
)

Add a listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

emit
(
  • type
  • object,...
)

Emit an event of certain type.

Parameters:

  • type String

    Event type.

  • [object,...] Object optional

    Event object(s).

listeners
(
  • type
)

Return the listener list bound to certain type of event.

Parameters:

  • type String

    Evnet type.

on
(
  • type
  • listener
)

Alias for EventEmitter.addListener(type, listener)

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

once
(
  • type
  • listener
)

Add a one-time listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

pause ()

Pause the playback.

play
(
  • notes
  • tempos
)

Play specified note and tempo.

Parameters:

  • notes Array

    Array of notes.

  • tempos Array

    Array of tempos.

Example:

buzzer.play(["C6","D6","E6","F6","G6","A6","B6"], ["8","8","8","8","8","8","8"]);
removeAllListeners
(
  • type
)

Remove all listeners of certain type.

Parameters:

  • type String

    Event type.

removeListener
(
  • type
  • listener
)

Remove a listener for certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

setMaxListeners
(
  • n
)

Set maximum number of listeners that is allow to bind on an emitter.

Parameters:

  • n Number

    Number of listeners.

stop ()

Stop the plaback.

tone
(
  • freq
  • duration
)

Set Buzzer tone.

Parameters:

  • freq Integer

    Frequency of tone.

  • duration Integer

    Duration of tone.

Properties

FREQUENCY

Number const static

Indicates the frequency of tone.

TONE_DELAY

Number const static

Indicates the delay of tone.

Attributes

type

String readonly

Type of the module.