Rewriting play-tone for correctness & clarity.
This commit is contained in:
parent
d1a3892eab
commit
324fd45fb6
@ -1,10 +1,10 @@
|
|||||||
# Play Tone
|
# Play Tone
|
||||||
|
|
||||||
Plays a music tone through pin ``P0`` for the given duration.
|
Play a musical tone through pin ``P0`` of the micro:bit for as long as you say.
|
||||||
|
|
||||||
## Simulator
|
## Simulator
|
||||||
|
|
||||||
Simulation of this function is available in many, but not all browsers.
|
This function only works on the micro:bit and in some browsers.
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
music.playTone(440, 120)
|
music.playTone(440, 120)
|
||||||
@ -12,11 +12,14 @@ music.playTone(440, 120)
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
* `frequency` : [Number](/reference/types/number) - the frequency of the note (in Herz)
|
* `Hz` is the [Number](/reference/types/number) of Hertz (the frequency, how high or low the tone is).
|
||||||
* `ms`: [Number](/reference/types/number) - the duration of the note (milliseconds)
|
* `ms` is the [Number](/reference/types/number) of milliseconds that the tone lasts.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
This example stores the musical note C in the variable `freq`.
|
||||||
|
Next, it plays that note for 1000 milliseconds (one second).
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let freq = music.noteFrequency(Note.C)
|
let freq = music.noteFrequency(Note.C)
|
||||||
music.playTone(freq, 1000)
|
music.playTone(freq, 1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user