# PWM out to speaker in simulator?

**URL:** <https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340>\
**Category:** Arcade\
**Created:** [January 4, 2021, 5:35pm UTC](https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340 "2021-01-04T17:35:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eanders](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/eanders/32/3134_2.png) [@eanders](https://forum.makecode.com/u/eanders)\
**Post date:** [January 4, 2021, 5:35pm UTC](https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340/1 "2021-01-04T17:35:55Z")

</div>

I’d like to use the Pins extension to send a PWM signal to the audio output device of the simulator – the same output destination where musical notes are played. Is this possible in the simulator? Is it bound to a pin?

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [January 4, 2021, 5:41pm UTC](https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340/2 "2021-01-04T17:41:03Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/afda7d0bea567efa41568706613d6089318725f6.png)

There is a number block, under the division block, that you can drag onto both parameters in the `play tone` block. The first parameter is the hertz and the second parameter is the duration in milliseconds.

---

<div class="post-metadata">

**Author:** ![eanders](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/eanders/32/3134_2.png) [@eanders](https://forum.makecode.com/u/eanders)\
**Post date:** [January 4, 2021, 7:20pm UTC](https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340/3 "2021-01-04T19:20:43Z")

</div>

Thank you for your reply! I think I asked the wrong question. What I want to do is manually set the output value of the pin that drives the speaker. This is straight forward on hardware, but I can’t seem to find a pin that will produce a sound in the simulator.

I want to experiment with combining wave oscillator values and sending the output to the speaker to make a rudimentary sound synthesizer. Thinking something like this cute app, but for meowbit: [https://apps.apple.com/us/app/bebot-robot-synth/id300309944](https://apps.apple.com/us/app/bebot-robot-synth/id300309944)

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [January 4, 2021, 7:43pm UTC](https://forum.makecode.com/t/pwm-out-to-speaker-in-simulator/5340/4 "2021-01-04T19:43:03Z")

</div>

BTW, you can play up to 5 notes at the same time, use the [timers](https://forum.makecode.com/t/timers-extension-after-x-debounce-throttle-and-in-background/1925) extension (which is now in the list of extensions in the editor) to play the notes in the background. You also have a limit of 2000 ms per note played.
