buzzer.playNotes

Category:Circuit Playground

Plays an array of notes one after the other.

buzzer.playNotes() is a method of the buzzer that plays an array of notes one after the other at a given tempo. All of the notes are played as a whole note; if you want to change how long a particular note is played for, you can use the buzzer.playSong() method.

This method accepts two parameters: a one-dimensional array full of notes, and a tempo to play them at. Tempo is an optional parameter, but if left undefined defaults to 120bpm.

Syntax

buzzer.playNotes(array, tempo)

Parameters

Name Type Required? Description
notes Array of Strings The array of notes to play.
tempo Number The speed at which to play the notes. Default speed is 120.

Tips

  • To add a pause in between notes, add a new item that contains null. null is a way to represent emptiness in computer science, and the buzzer.playNotes() method will read that as "Play nothing for the duration of a whole note".

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