buzzer.play()

Category:Circuit

Play a list of notes with the buzzer.

buzzer.play() is used to play an array of notes one after the other in one go. This can be used to craft actual songs as you can control the tempo (speed of how all of the notes will played) too.

Syntax

buzzer.play(notes, tempo);

Parameters

Name Type Required? Description
tempo Number The tempo determines the speed at which the list of notes will be played, in beats per minute (or bpm). If a tempo is not included, notes will play at a default tempo of 120 bpm
notes List This can either be a simple array of notes (such as `['C4', 'D4', 'E4']`), or a two dimensional array of notes and duration (eg `[['C4'], 1], [['D4'], 1/2], [['E4'], 1/4]`). Each note will be played in sequence from first (index 0) to last (index `notes.length - 1`).

Found a bug in the documentation? Let us know at documentation@code.org