buzzer.playNotes
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(notes, tempo)
Parameters
Name | Type | Required? | Description |
---|---|---|---|
notes | List | An array of notes (such as | |
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 |
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 thebuzzer.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 support@code.org.