Ring Tone

Play a musical tone on the speaker or at a sound pin of the micro:bit with the pitch as high or low as you say. The tone will keep playing until you tell it not to.

music.ringTone(440)

Simulator

The ||music:ring tone|| block works on the micro:bit board. It might not work in the simulator on every browser.

Parameters

  • frequency is a number that says how high-pitched or low-pitched the tone is. This number is in Hz (Hertz), which is a measurement of frequency or pitch.

Example

This program checks the accelerometer for the micro:bit’s acceleration (how much the micro:bit is speeding up or slowing down). Then it uses that acceleration to make a tone. If the micro:bit speeds up, the tone’s pitch gets higher, and if it slows down, the tone’s pitch gets lower. It’s fun – try it!

basic.forever(() => {
    music.ringTone(input.acceleration(Dimension.X))
})

Using other pins

Use analogSetPitchPin to change that pin used to generate music.

pins.analogSetPitchPin(AnalogPin.P1);

See also

rest, play tone, tempo, set tempo, change tempo by