Analog Pitch

Sends a pulse-width modulation (PWM) signal to the pin P0.

pins.analogPitch(440, 300)

The PWM signal is sent to the current pitch pin. Use analog set pitch pin to first set the current pitch pin.


  • frequency: a number which is the frequency of the PWM signal at the pitch pin.
  • ms: a number in milliseconds that is the duration of the signal at the pitch pin.


Set the pitch pin to P1 and send a 440 Hz tone for 1 second.

let frequency1 = 440
let duration = 1000
pins.analogPitch(frequency1, duration)

Some common notes

See also

micro:bit pins, analog set period, analog set pitch pin